Should a method name shadow outer names when quoted or with PEP563? #18525
Labels
bug
mypy got something wrong
topic-quoted-annotations
Detecting problems with quoted annotations
topic-runtime-semantics
mypy doesn't model runtime semantics correctly
Bug Report
If a class defines a method with a name shadowing outer name,
mypy
always rejects it in annotations.To Reproduce
Consider the following snippet (playground):
When run against it,
mypy
is producing a correctvalid-type
error, matching runtime behaviour.Now let's uncomment the future import or quote
list[int]
(both behave equivalently).Runtime resolution also (unsurprisingly, probably) works as intended, so
mypy
does not model runtime semantics correctly?Expected Behavior
Snippet with PEP563 enabled should pass
mypy
checkActual Behavior
Your Environment
mypy.ini
(and other config files): N/AThe text was updated successfully, but these errors were encountered: