Skip to content

Namespace issue with DesignUnit #100

@domWalters

Description

@domWalters

In __init__.py, the DesignUnit class is imported from the DesignUnit file and retains its name.

As a result, it overwrites the DesignUnit module.

So, the following causes an error:

import pyVHDLModel

class LibraryClause(pyVHDLModel.DesignUnit.LibraryClause):
    ...
    class LibraryClause(pyVHDLModel.DesignUnit.LibraryClause):
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E   AttributeError: type object 'DesignUnit' has no attribute 'LibraryClause'

This is because type(pyVHDLModel.DesignUnit) == <class DesignUnit>.

You have to do a from ... import to avoid this issue:

from pyVHDLModel.DesignUnit import LibraryClause as BaseLibraryClause

class LibraryClause(BaseLibraryClause):
    ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions