-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
[Bug report] Name '...' is not defined when wildcard importing local module #8497
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
Comments
Most likely you are using Also I have no idea how do you run Python, but without that
|
There is actually an Note : I do not run mypy with the As you can see on the image below, I import a bunch of constants (one of them is called
The import succeeds, and as you can see the Python extension in VSCode even recognizes the type of
Pylint doesn't detect any error here, neither does the Python extension, and this module works without a problem at runtime, so I can assure you that this seems to be a false positive on mypy's side. I am wondering if this is linked to the fact that I use Poetry to handle the dependencies (including the local packages) on this project. I can try and create an actual minimal reproducible project this weekend so that it is clearer where the bug may originate from, if you want. |
Yes, we can't really proceed without this. |
@ilevkivskyi I have found that my original issue originates from the fact that there was no However, I am wondering if this is really expected behavior, since when using named imports (as opposed to wildcard imports), mypy apparently has no problem recognizing the imported variables even if __init__.py files are missing. This behavior seems a little inconsistent. On top of that, is there a reason why mypy would sometimes require |
Mypy version : 0.761
Mypy outputs an error
Name 'MY_CONSTANT' is not defined
whenMY_CONSTANT
has been imported through a wildcard import of a local module. The error doesn't appear when I wildcard import a standard library module for instance (such asfrom math import *
.This is definitely a false positive, since I can run
main.py
without any error.Example code :
The module in question :
Simplified project architecture :
The text was updated successfully, but these errors were encountered: