| n | from typing import Protocol, TypeVar, overload, Any | n | from typing import Any, Protocol, TypeVar, overload |
| T = TypeVar('T') | | T = TypeVar('T') |
| | | |
| n | class MulAddInt(Protocol[T]): | n | class SupportsMulSum(Protocol[T]): |
| | | |
| n | def __mul__(self, n: int) -> T: | n | def __mul__(self, n: int, /) -> T: |
| ... | | ... |
| | | |
| n | def __rmul__(self, n: int) -> T: | n | def __rmul__(self, n: int, /) -> T: |
| ... | | ... |
| | | |
| n | def __add__(self, other: T) -> T: | n | def __add__(self, other: T, /) -> T: |
| ... | | ... |
| n | U = TypeVar('U') | n | E = TypeVar('E') |
| | | |
| @overload | | @overload |
| n | def anymulsum(a: list[U], b: int, c: list[U]) -> list[U]: | n | def anymulsum(a: list[E], b: int, c: list[E], /) -> list[E]: |
| ... | | ... |
| | | |
| @overload | | @overload |
| n | def anymulsum(a: MulAddInt[T], b: int, c: T) -> T: | n | def anymulsum(a: SupportsMulSum[T], b: int, c: T, /) -> T: |
| ... | | ... |
| | | |
| t | def anymulsum(a: Any, b: int, c: Any) -> Any: | t | def anymulsum(a: Any, b: int, c: Any, /) -> Any: |
| return a * b + c | | return a * b + c |