We currently narrow like this:
class A[T]: ...
def _(x: A[int] | int):
if isinstance(x, A):
reveal_type(x) # revealed: (A[int] & A[Unknown]) | (int & A[Unknown])
else:
reveal_type(x) # revealed: (A[int] & ~A[Unknown]) | (int & ~A[Unknown])
Ideally we would reveal:
class A[T]: ...
def _(x: A[int] | int):
if isinstance(x, A):
reveal_type(x) # revealed: A[int]
else:
reveal_type(x) # revealed: int
We currently narrow like this:
Ideally we would reveal: