-
Notifications
You must be signed in to change notification settings - Fork 134
Closed
astral-sh/ruff
#20256Labels
bugSomething isn't workingSomething isn't workinggenericsBugs or features relating to ty's generics implementationBugs or features relating to ty's generics implementationnarrowingrelated to flow-sensitive type narrowingrelated to flow-sensitive type narrowing
Milestone
Description
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: intlczyk and ierezell
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggenericsBugs or features relating to ty's generics implementationBugs or features relating to ty's generics implementationnarrowingrelated to flow-sensitive type narrowingrelated to flow-sensitive type narrowing