You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(venv) $ tree .
.
├── alpha.py
└── beta.py
1 directory, 2 files
(venv) $ cat alpha.py
from beta import Class2
class Class1:
obj = Class2()
(venv) $ cat beta.py
from alpha import Class1
class Class2:
obj = Class1()
Python fails with the ImportError as expected:
(venv) $ python alpha.py
Traceback (most recent call last):
File "/cur/dir/alpha.py", line 1, in<module>
from beta import Class2
File "/cur/dir/beta.py", line 1, in<module>
from alpha import Class1
File "/cur/dir/alpha.py", line 1, in<module>
from beta import Class2
ImportError: cannot import name 'Class2' from partially initialized module 'beta' (most likely due to a circular import) (/cur/dir/beta.py)
pycycle detects the cycle as expected:
(venv) $ pycycle --here
Project successfully transformed to AST, checking imports for cycles..
Cycle Found :(
alpha -> beta: Line 1 =>> alpha
Finished.
Create an empty __init__.py in the directory. After that pycycle can no longer detect the cycle.
(venv) $ touch __init__.py
(venv) $ pycycle --here
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.
The text was updated successfully, but these errors were encountered:
Have a circular import
Python fails with the
ImportError
as expected:pycycle
detects the cycle as expected:Create an empty
__init__.py
in the directory. After thatpycycle
can no longer detect the cycle.The text was updated successfully, but these errors were encountered: