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
Circular import detected when module exported in __init__.py
imports another module from the same package
#1864
Comments
The You've already discovered the approach I would recommend — to change the import statement in The cycle detection logic in pylance is an advanced (strict-mode) feature that is off by default. Some cycles that it detects may not cause problems at runtime, but they can result in code fragility that will result in a runtime error when code is modified. If you prefer, you can leave it disabled. |
Yeah; @erictraut thanks; is this a non-issue? |
I'm hitting the exact same issue. I ended up disabling this rule because importing lots of objects directly from the module instead of importing the module itself tends to pollute the namespace, which makes code harder to read and write. Yet, as @ravindUwU noted, it still feels wrong to disable this rule just because I completely understand the rationale behind the rule so closing this as wontfix may be acceptable, but maybe adding an option to skip the |
Closing old issue. If this is still a problem, please reopen with the information requested. thanks |
In a VSCode workspace with
"python.analysis.typeCheckingMode": "strict"
and the following project structure,Pylance detects a circular import because
primary.Foo
importssecondary.Foo
from the same package via thefrom . import ...
statement. Is this expected? 🤔Importing
secondary.Foo
via afrom .secondary import Foo as SecondaryFoo
works.Expected behaviour
(No errors)
Actual behaviour
Error at
pack/__init__.py:1
.Environment data
v2021.9.3
19043.1237
3.9.7
Logs
Python Language Server
The text was updated successfully, but these errors were encountered: