basedmypy
basedmypy copied to clipboard
return type on `isinstance` check with non-overlapping types is `bool` instead of `False`
Describe the problem, ie expected/actual result (if it's not blatantly obvious)
this prevents you from being able to use cast to work around redundant-expr false positives (eg. #615)
Gist to reproduce
# mypy: enable-error-code=redundant-expr
from typing import cast
b = 1
reveal_type(isinstance(b, str)) # bool, should be False
if isinstance(b, str): # error: condition is always false
...
if cast(bool, isinstance(b, str)): # error: redundant expr
...