-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
A rather primitive module cycle is not detected. Minimal working example:
reproduction
├── __init__.py
├── moduleA
│ ├── __init__.py
│ └── a_class.py
└── moduleB
├── __init__.py
└── b_class.py
reproduction > moduleA > __init__.py:
from .a_class import ClassAreproduction > moduleA > a_class.py:
import reproduction.moduleB
class ClassA:
passreproduction > moduleB > __init__.py:
from .b_class import ClassBreproduction > moduleB > b_class.py:
from ..moduleA import ClassA
class ClassB:
passWhen running pycycle:
> pycycle --here --verbose
Trying to parse file: /private/tmp/reproduction/reproduction/__init__.py
Trying to parse file: /private/tmp/reproduction/reproduction/moduleB/__init__.py
Trying to parse file: /private/tmp/reproduction/reproduction/moduleB/b_class.py
Trying to parse file: /private/tmp/reproduction/reproduction/moduleA/a_class.py
Trying to parse file: /private/tmp/reproduction/reproduction/moduleA/__init__.py
Project successfully transformed to AST, checking imports for cycles..
No worries, no cycles here!
If you think some cycle was missed, please open an Issue on Github.
Finished.when trying to import moduleA:
> python3 -c 'import reproduction.moduleA'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/reproduction/reproduction/moduleA/__init__.py", line 1, in <module>
from .a_class import ClassA
File "/private/tmp/reproduction/reproduction/moduleA/a_class.py", line 1, in <module>
import reproduction.moduleB
File "/private/tmp/reproduction/reproduction/moduleB/__init__.py", line 1, in <module>
from .b_class import ClassB
File "/private/tmp/reproduction/reproduction/moduleB/b_class.py", line 1, in <module>
from ..moduleA import ClassA
ImportError: cannot import name 'ClassA' from partially initialized module 'reproduction.moduleA' (most likely due to a circular import) (/private/tmp/reproduction/reproduction/moduleA/__init__.py)Metadata
Metadata
Assignees
Labels
No labels