Open
Description
From version 1.1.380 onwards, Pyright erroneously reports the isinstance
below as unnecessary:
class A:
...
class B(A):
...
class C(A):
...
def f(elem: B | C, _type: type[A]) -> bool:
return isinstance(elem, _type)
assert f(B(), B)
assert not f(B(), C)
That would be correct only if type
were invariant.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment