-
-
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
false-positive name-defined
regression with dataclasses and shadowing
#12907
Labels
bug
mypy got something wrong
topic-dataclasses
topic-runtime-semantics
mypy doesn't model runtime semantics correctly
topic-variable-scope
Comments
AlexWaygood
added
topic-dataclasses
topic-runtime-semantics
mypy doesn't model runtime semantics correctly
topic-variable-scope
labels
May 30, 2022
I suspect that the original behavior was accidental. Now dataclass behavior is similar to ordinary classes, since #12762 made dataclasses a little less special: import collections
class Shadow:
collections: collections.deque
other: collections.defaultdict # Error here This is still a regression. As a workaround, you can import import collections as _collections
class Shadow:
collections: _collections.deque
other: _collections.defaultdict # OK I'm going to try to find a simple fix, but I think that we can live with this regression if there is no easy fix in sight. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
mypy got something wrong
topic-dataclasses
topic-runtime-semantics
mypy doesn't model runtime semantics correctly
topic-variable-scope
Bug Report
This file:
is perhaps a bit unorthodox, but runs fine, because the
collections: ...
doesn't actually shadow the module when definingother
.Actual Behavior
mypy v0.950 was happy with it, but mypy v0.960 claims that:
Introducing commit
Bisected to 03901ef ("Running dataclass transform in a later pass to fix crashes (#12762)", @JukkaL)
Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: