callable invariance rears its head again

This commit is contained in:
Douglas Creager 2025-12-05 16:40:59 -05:00
parent a372e63b2c
commit d47e9a60df
1 changed files with 2 additions and 1 deletions

View File

@ -478,7 +478,8 @@ class C[**P]:
def __init__(self, f: Callable[P, int]) -> None: def __init__(self, f: Callable[P, int]) -> None:
self.f = f self.f = f
def f(x: int, y: str) -> bool: # Note that the return type must match exactly, since C is invariant on the return type of C.f.
def f(x: int, y: str) -> int:
return True return True
c = C(f) c = C(f)