idiombench / Python /train /3.13 /protocol /modern_18.py
SwashBuckler001's picture
IdiomBench (part 7)
5eb110b verified
Raw History Blame Contribute Delete
299 Bytes
from typing import Any, Protocol
class ProtoA(Protocol):
def meth(self, x: int) -> int: ...
class ProtoB(Protocol):
def meth(self, obj: Any, x: int) -> int: ...
class C:
def meth(self, x: int) -> int: ...
a: ProtoA = C # Type check error, signatures don't match!
b: ProtoB = C # OK