-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
__spec__ incorrectly flagged as not existing in the global/module namespace #4145
Labels
bug
mypy got something wrong
priority-1-normal
topic-runtime-semantics
mypy doesn't model runtime semantics correctly
Comments
brettcannon
changed the title
__spec__ defined in a module's namespace is claimed as not defined
__spec__ incorrectly flagged as not existing in the global/module namespace
Oct 20, 2017
It's probably just missing __spec__ in the typeshed stub for ModuleType
in types.pyi.
|
I think this is similar to #1422, should be not hard to fix, but this requires an addition to |
@ilevkivskyi You're right, |
AlexWaygood
added
the
topic-runtime-semantics
mypy doesn't model runtime semantics correctly
label
Mar 27, 2022
I just bumped on this. Could we add support for |
achimnol
added a commit
to lablup/backend.ai
that referenced
this issue
Feb 16, 2023
hauntsaninja
added a commit
to hauntsaninja/mypy
that referenced
this issue
Feb 20, 2023
Fixes python#4145 It was too annoying to get the fixtures to work out here, so I didn't. But you can see the tests will add the None for the non `__main__` case
hauntsaninja
added a commit
that referenced
this issue
May 21, 2024
Fixes #4145 Co-authored-by: Joongi Kim <me@daybreaker.info>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
mypy got something wrong
priority-1-normal
topic-runtime-semantics
mypy doesn't model runtime semantics correctly
If you have code in a module that wants to access a module's
__spec__
attribute through the global namespace, mypy claims thaterror: Name '__spec__' is not defined
. E.g.@unittest.skipIf(__spec__ is None, '__spec__ is None')
. This same issue doesn't come up for__name__
or__path__
.The text was updated successfully, but these errors were encountered: