pycycle icon indicating copy to clipboard operation
pycycle copied to clipboard

No Cycles detected

Open Godcreatebugs opened this issue 3 years ago • 4 comments

My code have structure like this. I have multiple modules and

A modules import B modules to work, B import C and C needs B to work. There are other dependancies are involved as well. But , this is general idea. I get 'No Cycles detected'.

Godcreatebugs avatar May 19 '21 17:05 Godcreatebugs

Please share a minimal reproductible code otherwise we can’t understand the problem.

bfontaine avatar Aug 16 '21 08:08 bfontaine

It seems that pycycle does not find package content:

(venv) /tmp/tmp.pSbwX4HflM$ find p -type f | xargs cat
# p/a.py
import b

b.foo()
# p/b.py
import a

a.bar()
# p/__init__.py
from .a import f
from .b import g

__all__ = ["f", "g"]
(venv) /tmp/tmp.pSbwX4HflM$ 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.
(venv) /tmp/tmp.pSbwX4HflM$ pip show pycycle
Name: pycycle
Version: 0.0.8
Summary: Find and repair your import cycles in any project
Home-page: https://github.com/bndr/pycycle
Author: Vadim Kravcenko
Author-email: [email protected]
License: MIT
Location: /tmp/tmp.pSbwX4HflM/venv/lib/python3.8/site-packages
Requires: pytest, click, crayons, click-completion
Required-by: 

(venv) /tmp/tmp.pSbwX4HflM$ cd p
(venv) /tmp/tmp.pSbwX4HflM/p$ pycycle --here
Project successfully transformed to AST, checking imports for cycles..
Cycle Found :(
b -> a: Line 2 =>> b
Finished.

xtofl avatar Mar 08 '22 11:03 xtofl

Also, I would expect an 'incremental' behavior: if folder a/b/c contains a cycle, so does a/b. This is currently not the case:

$ git describe
v0.0.7-2-gb93822c

# GOOD:
$ pycycle --source tests/_projects/large_circle
Target source provided: /home/kristoffel/opensource/pycycle/tests/_projects/large_circle
Project successfully transformed to AST, checking imports for cycles..
Cycle Found :(
a_module.a_file -> a_module.b_module.b_file: Line 1 -> c_file: Line 1 -> d_file: Line 1 =>> a_module.a_file
Finished.

# BAD!
$ pycycle --source tests/_projects/
Target source provided: /home/kristoffel/opensource/pycycle/tests/_projects
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.

(note: this was after fixing the --source argument as suggested in #22 .)

xtofl avatar Mar 08 '22 12:03 xtofl

I have similar issue. Basically if I copy you example "large_circle" somewhere deep inside my project it is missed. I fixed import names to subfolder. If I copy run.py into root folder it is found.

Since we are using Django a lot of code is dynamically loaded and not referenced from the root folder. Zero cycles found even if I introduce very simple one.

matejsp avatar Sep 10 '22 06:09 matejsp