pyVHDLModel icon indicating copy to clipboard operation
pyVHDLModel copied to clipboard

Namespace issue with `DesignUnit`

Open domWalters opened this issue 7 months ago • 0 comments

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):
    ...

domWalters avatar Jul 14 '25 15:07 domWalters