basedmypy
basedmypy copied to clipboard
Incorrect `redundant-expr` error for `isinstance` on constrained `TypeVar`s
Describe the problem, ie expected/actual result (if it's not blatantly obvious)
def f[T: (int, str)](t: T):
if isinstance(t, int): # always true and always false
...
Gist to reproduce
https://mypy-play.net/?mypy=basedmypy-latest&python=3.12&gist=fd75669322cbcbe6bb7c20b985768813
Basedmypy version
basedmypy 2.5.0 (compiled: yes)
additionally:
def true() -> True: ...
def false() -> False: ...
if bool() and true(): ...
if bool() and false(): ...
https://github.com/KotlinIsland/basedmypy/issues/725