You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mypy thinks variable is None even if assigned non-None value inside loop #11900
I believe the problem might be something around the keywordis. Here are my test cases:
The first one is the case you provided:
And the second test case is:
I changed the keyword is to the operator == and it shows that mypy detects the error. Therefore, I believe the problem can be located with the keyword is.
I will continue working on this by further inspecting the source code and updating my process! However, I am new to mypy and not familiar with that. It would be best if you can provide me with some information that which files I should pay more attention to.
Activity
Akuli commentedon Jan 4, 2022
Workaround:
user: int | None = Noneoruser: Optional[int] = Nonezhangck981 commentedon Apr 2, 2022
I believe the problem might be something around the keyword


is. Here are my test cases:The first one is the case you provided:
And the second test case is:
I changed the keyword
isto the operator==and it shows that mypy detects the error. Therefore, I believe the problem can be located with the keywordis.I will continue working on this by further inspecting the source code and updating my process! However, I am new to mypy and not familiar with that. It would be best if you can provide me with some information that which files I should pay more attention to.
A5rocks commentedon Jan 22, 2025
Fixed by #18433.