Content-Length: 224058 | pFad | https://github.com/python/mypy/issues/9991

7F Class scope name resolution issue · Issue #9991 · python/mypy · GitHub
Skip to content

Class scope name resolution issue #9991

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

Open
hauntsaninja opened this issue Jan 29, 2021 · 0 comments
Open

Class scope name resolution issue #9991

hauntsaninja opened this issue Jan 29, 2021 · 0 comments
Labels
bug mypy got something wrong good-second-issue priority-2-low topic-runtime-semantics mypy doesn't model runtime semantics correctly topic-variable-scope

Comments

@hauntsaninja
Copy link
Collaborator

Example courtesy of @gvanrossum , based on https://twitter.com/gvanrossum/status/1354305179244392453

While Python's behaviour is surprising, mypy should match it.

from typing import *

x: Optional[int] = None
y: Optional[int] = None

def f() -> None:
    x = 1
    y = 1
    class C:
        reveal_type(x)  # Correctly reveals int
        reveal_type(y)  # Incorrectly reveals int, should be Optional[int]
        x = 2

I also found https://bugs.python.org/issue24129 interesting. Thanks, ilevkivskyi!

@hauntsaninja hauntsaninja added bug mypy got something wrong priority-2-low labels Jan 29, 2021
@AlexWaygood AlexWaygood added topic-runtime-semantics mypy doesn't model runtime semantics correctly topic-variable-scope labels Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong good-second-issue priority-2-low topic-runtime-semantics mypy doesn't model runtime semantics correctly topic-variable-scope
Projects
None yet
Development

No branches or pull requests

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/python/mypy/issues/9991

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy