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
@A5rocks found the following bug when discussing #19118:
deff4() ->None:
whileint():
try:
x=1ifint():
x=""breakifint():
whileint():
ifint():
x=Nonebreakfinally:
ifisinstance(x, str):
print("hello :)") # E: Statement is unreachablereveal_type(x) # N: Revealed type is "Union[builtins.int, builtins.str, None]
This bug does not need a loop and hence can be simplified to:
# Mypy 1.16.0# --allow-redefinition-new --local-partial-types --warn-unreachabledeff() ->None:
try:
x=1ifint():
x=""returnifint():
x=Nonereturnfinally:
reveal_type(x) # N: Revealed type is "Union[builtins.int, builtins.str, None]" \# N: Revealed type is "builtins.int"ifisinstance(x, str): # E: Subclass of "int" and "str" cannot exist: would have incompatible method signaturesreveal_type(x) # E: Statement is unreachable \# E: Revealed type is "builtins.str"reveal_type(x) # N: Revealed type is "Union[builtins.int, builtins.str, None]" \# N: Revealed type is "builtins.int"
@A5rocks found the following bug when discussing #19118:
This bug does not need a loop and hence can be simplified to:
A first idea on how to fix this.
The text was updated successfully, but these errors were encountered: