We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Bug Report
After foo = None, mypy thinks that foo will always be None, even if a loop can jump between the assignment and the use of foo.
foo = None
foo
None
To Reproduce
def main() -> None: gonna_select = None while True: if gonna_select is not None: print(1 + "lol") gonna_select = "lol"
Expected Behavior
error from 1 + "lol"
1 + "lol"
Actual Behavior
no error
Your Environment
mypy.ini
The text was updated successfully, but these errors were encountered:
def main() -> None: gonna_select = None while True: gonna_select = "lol" # ^^^^^^^^^^^^^^^^^^
I think the real error should be here. Since mypy infers gonna_select as type None, why does it allow assigning a string to it?
gonna_select
Sorry, something went wrong.
Fixed by #18433
No branches or pull requests
Bug Report
After
foo = None
, mypy thinks thatfoo
will always beNone
, even if a loop can jump between the assignment and the use offoo
.To Reproduce
Expected Behavior
error from
1 + "lol"
Actual Behavior
no error
Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: