Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Subpackage circular imports not detected #15

Open
DomHudson opened this issue Apr 2, 2020 · 0 comments
Open

Bug: Subpackage circular imports not detected #15

DomHudson opened this issue Apr 2, 2020 · 0 comments

Comments

@DomHudson
Copy link

DomHudson commented Apr 2, 2020

Summary

My example is the following package structure where package.subpackage.module imports from package.module and visa-versa.

.
├── package
│   ├── __init__.py
│   ├── module.py
│   └── subpackage
│       ├── __init__.py
│       └── module.py
└── run.py

run.py

from package.module import Anything

package/subpackage/module.py

from package.module import Anything


class Thing:
    pass

package/module.py

from package.subpackage.module import Thing


class Anything:
    pass

Expected behaviour

I consider this a circular import but pycycle detects no errors.

Executing run.py results in a circular import error:

Traceback (most recent call last):
  File "run.py", line 1, in <module>
    from package.module import Anything
  File "/home/dom/Code/package/package/module.py", line 1, in <module>
    from package.subpackage.module import Thing
  File "/home/dom/Code/package/package/subpackage/module.py", line 1, in <module>
    from package.module import Anything
ImportError: cannot import name 'Anything' from 'package.module' (/home/dom/Code/package/package/module.py)

An archive containing the package structure and code.
package.tar.gz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant