Skip to content
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

Mypy misses conditional name not defined errors #11006

Closed
Dreamsorcerer opened this issue Aug 21, 2021 · 2 comments
Closed

Mypy misses conditional name not defined errors #11006

Dreamsorcerer opened this issue Aug 21, 2021 · 2 comments
Labels
bug mypy got something wrong

Comments

@Dreamsorcerer
Copy link
Contributor

if False:
    bar = "a"

print(bar)

Mypy passes successfully on this code. Python obviously errors with NameError: name 'bar' is not defined at runtime.

Mypy should ensure that a variable when referenced has been defined in all possible paths of execution up to that point.

@Dreamsorcerer Dreamsorcerer added the bug mypy got something wrong label Aug 21, 2021
@erictraut
Copy link

This is related to #2400 and #686

@Dreamsorcerer
Copy link
Contributor Author

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants