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
in this scenario, while a is a local variable the lifetime of it is determined by the if and return so there is no overlap between the case when a is a str and when is an int or a bool - those are "effectively" different variables.
Expected Behavior
no error triggered by mypy
Actual Behavior
main.py:13: error: Incompatible types in assignment (expression has type "int", variable has type "str") [assignment]
main.py:16: error: Incompatible types in assignment (expression has type "bool", variable has type "str") [assignment]
Found 2 errors in 1 file (checked 1 source file)
The text was updated successfully, but these errors were encountered:
it's a bit of a "extended variant" (the concrete usecase is a bit different as is with if / else branches vs early return) but the gist is the same, yep
Playground url: https://mypy-play.net/?mypy=latest&python=3.12&flags=strict%2Cwarn-unused-configs&gist=d2e9766efcc27a2bc27d7226c0f6b444
in this scenario, while
a
is a local variable the lifetime of it is determined by theif
andreturn
so there is no overlap between the case whena
is astr
and when is anint
or abool
- those are "effectively" different variables.Expected Behavior
no error triggered by
mypy
Actual Behavior
The text was updated successfully, but these errors were encountered: