Protocols with restrictions on `self` or `cls` receiver parameters are not supported
Author: sharkdpCreated Sep 17, 2026Updated Sep 17, 2026
Labelsset-theoretic typesprotocolsmethod-receiver
This should work, but doesn't:
from typing import Protocol, Self
class Other: ...
class P(Protocol):
def restricted(self: Self & Other) -> None: ...
class C:
def restricted(self: Self & Other) -> None: ...
p: P = C() # ty: Object of type `C` is not assignable to `P`The same issue exists for classmethods which take a cls: type[Self & Other] parameter.
Source: astral-sh/ty