Closed
Description
Code like this currently fails but should be okay:
def f(x: Union[int, str]) -> None:
if not isinstance(x, int):
return
x + 2 # x must be int here so this is okay, but mypy complains
Note that this works currently (without the not
operator):
def f(x: Union[int, str]) -> None:
if isinstance(x, str):
return
x + 2 # this is considered valid, as it should be