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
I think this is more of a type-narrowing issue, rather than reachability.
To narrow types, you have to look at the scope of the name being narrowed (the narrowee), and the scopes of all of the functions called during the narrowed time.
As soon as a function is called that could possibly access the scope of the narrowee, the narrowing is gone.
If someone wants to make sure their type gets narrowed, they can make a local variable, and then only call functions that are defined outside of the local scope.
Akuli
changed the title
if statements type narrowing leads to "unreachable" code being actually reachable
type narrowing leads to "unreachable" code being actually reachable
Apr 29, 2022
Bug Report
To Reproduce
Expected Behavior
An error for the obviously wrong
print(1 + "lol")
. It fails there at runtime.Actual Behavior
no errors!
Your Environment
mypy 0.942 with
--python-version 3.10
The text was updated successfully, but these errors were encountered: