from typing import Protocol, TypeVar, Generic T = TypeVar("T") class Adder(Generic[T], Protocol): def add(self, a: T, b: T) -> T: ... class AdderImpl(Adder[int]): acc: int def add(self, a: int, b: int): self.acc = a + b return self.acc