-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 narrowing with reassignment in loop #11612
Labels
bug
mypy got something wrong
topic-reachability
Detecting unreachable code
topic-type-narrowing
Conditional type narrowing / binder
Comments
This can be fixed by: a: int | None = None
for b in [1, 2]:
if a is None:
a = b
continue
print("hi") # ok The other question is: why |
It is, if you put Perhaps it is inferring as |
@sobolevn It's not just the inference, I've updated the OP with a much better example. |
KotlinIsland
added a commit
to KotlinIsland/basedmypy
that referenced
this issue
Nov 13, 2023
KotlinIsland
added a commit
to KotlinIsland/basedmypy
that referenced
this issue
Nov 14, 2023
tyralla
added a commit
to tyralla/mypy
that referenced
this issue
Jan 9, 2025
Fixes python#18348 Fixes python#13973 Fixes python#11612 Fixes python#8721 Fixes python#8865 Fixes python#7204 I manually checked all the listed issues. Some of them were already partly fixed by python#18180.
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-reachability
Detecting unreachable code
topic-type-narrowing
Conditional type narrowing / binder
Also:
The text was updated successfully, but these errors were encountered: