Move a few protocol from builtins to _typeshed (#7736)

This commit is contained in:
Sebastian Rittau
2022-04-28 17:36:47 +02:00
committed by GitHub
parent 5535b7fc08
commit 5df8de7693
2 changed files with 22 additions and 13 deletions

View File

@@ -64,12 +64,27 @@ class SupportsAllComparisons(SupportsDunderLT, SupportsDunderGT, SupportsDunderL
SupportsRichComparison: TypeAlias = SupportsDunderLT | SupportsDunderGT
SupportsRichComparisonT = TypeVar("SupportsRichComparisonT", bound=SupportsRichComparison) # noqa: Y001
# Dunder protocols
class SupportsAdd(Protocol):
def __add__(self, __x: Any) -> Any: ...
class SupportsDivMod(Protocol[_T_contra, _T_co]):
def __divmod__(self, __other: _T_contra) -> _T_co: ...
class SupportsRDivMod(Protocol[_T_contra, _T_co]):
def __rdivmod__(self, __other: _T_contra) -> _T_co: ...
# This protocol is generic over the iterator type, while Iterable is
# generic over the type that is iterated over.
class SupportsIter(Protocol[_T_co]):
def __iter__(self) -> _T_co: ...
# This protocol is generic over the iterator type, while AsyncIterable is
# generic over the type that is iterated over.
class SupportsAiter(Protocol[_T_co]):
def __aiter__(self) -> _T_co: ...
class SupportsLenAndGetItem(Protocol[_T_co]):
def __len__(self) -> int: ...
def __getitem__(self, __k: int) -> _T_co: ...