| f | from typing import Any, Protocol, TypeVar, overload | f | from typing import Any, Protocol, TypeVar, overload |
| n | R = TypeVar('R') | n | T1 = TypeVar('T1') |
| E = TypeVar('E') | | T2 = TypeVar('T2') |
| | | |
| n | class P(Protocol[R]): | n | class P(Protocol[T1]): |
| | | |
| n | def __mul__(self, n: int, /) -> R: | n | def __mul__(self, n: int, /) -> T1: |
| ... | | ... |
| | | |
| n | def __add__(self, x: R, /) -> R: | n | def __add__(self, x: T1, /) -> T1: |
| ... | | ... |
| | | |
| class _AnyMulSum: | | class _AnyMulSum: |
| | | |
| @overload | | @overload |
| n | def __call__(self, a: list[E], b: int, c: list[E]) -> list[E]: | n | def __call__(self, a: list[T2], b: int, c: list[T2]) -> list[T2]: |
| ... | | ... |
| | | |
| @overload | | @overload |
| t | def __call__(self, a: P[R], b: int, c: R) -> R: | t | def __call__(self, a: P[T1], b: int, c: T1) -> T1: |
| ... | | ... |
| | | |
| def __call__(self, a: Any, b: int, c: Any) -> Any: | | def __call__(self, a: Any, b: int, c: Any) -> Any: |
| return a * b + c | | return a * b + c |
| anymulsum = _AnyMulSum() | | anymulsum = _AnyMulSum() |