(a)next only requires __(a)next__, not Iterator (#6036)

This commit is contained in:
Sebastian Rittau
2021-09-14 10:43:21 +02:00
committed by GitHub
parent 8a704ab290
commit b562d233ae
2 changed files with 15 additions and 5 deletions

View File

@@ -6,7 +6,7 @@ import array
import mmap
import sys
from os import PathLike
from typing import AbstractSet, Any, Container, Iterable, Protocol, Tuple, TypeVar, Union
from typing import AbstractSet, Any, Awaitable, Container, Iterable, Protocol, Tuple, TypeVar, Union
from typing_extensions import Literal, final
_KT = TypeVar("_KT")
@@ -26,6 +26,14 @@ Self = TypeVar("Self") # noqa Y001
class IdentityFunction(Protocol):
def __call__(self, __x: _T) -> _T: ...
# stable
class SupportsNext(Protocol[_T_co]):
def __next__(self) -> _T_co: ...
# stable
class SupportsAnext(Protocol[_T_co]):
def __anext__(self) -> Awaitable[_T_co]: ...
class SupportsLessThan(Protocol):
def __lt__(self, __other: Any) -> bool: ...