-
Notifications
You must be signed in to change notification settings - Fork 139
Closed
astral-sh/ruff
#18368Labels
bugSomething isn't workingSomething isn't workingset-theoretic typesunions, intersections and moreunions, intersections and more
Description
Summary
An intersection like bool & Callable[..., int] should be Never, because bool can't have any subclasses that are callable. But ty treats it as irreducible.
from typing import Callable, reveal_type, Literal, final
from ty_extensions import Intersection
@final
class C:
pass
def f(
x: Intersection[bool, Callable[..., int]],
y: Intersection[Literal[1], Callable[..., int]],
z: Intersection[C, Callable[..., int]],
):
reveal_type(x) # bool & ((...) -> int), expect Never
reveal_type(y) # Never (correct)
reveal_type(z) # C & (...) -> int), expect Neverhttps://play.ty.dev/979ab089-7157-44ad-a94a-868260108090
An intersection between a final class and a non-applicable Protocol is correctly reduced to Never though.
Version
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingset-theoretic typesunions, intersections and moreunions, intersections and more