basedmypy icon indicating copy to clipboard operation
basedmypy copied to clipboard

Incorrect `redundant-expr` error for `isinstance` on constrained `TypeVar`s

Open Loch64 opened this issue 1 year ago • 1 comments

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)

Loch64 avatar Aug 01 '24 05:08 Loch64

additionally:

def true() -> True: ...
def false() -> False: ...

if bool() and true(): ...
if bool() and false(): ...

https://github.com/KotlinIsland/basedmypy/issues/725

KotlinIsland avatar Aug 01 '24 05:08 KotlinIsland