@@ -28,8 +28,6 @@ from typing import (
2828 IO ,
2929 AbstractSet ,
3030 Any ,
31- AsyncIterable ,
32- AsyncIterator ,
3331 BinaryIO ,
3432 ByteString ,
3533 Callable ,
@@ -76,6 +74,14 @@ _T5 = TypeVar("_T5")
7674_TT = TypeVar ("_TT" , bound = "type" )
7775_TBE = TypeVar ("_TBE" , bound = "BaseException" )
7876_R = TypeVar ("_R" ) # Return-type TypeVar
77+ _SupportsNextT = TypeVar ("_SupportsNextT" , bound = SupportsNext [Any ], covariant = True )
78+ _SupportsAnextT = TypeVar ("_SupportsAnextT" , bound = SupportsAnext [Any ], covariant = True )
79+
80+ class _SupportsIter (Protocol [_T_co ]):
81+ def __iter__ (self ) -> _T_co : ...
82+
83+ class _SupportsAiter (Protocol [_T_co ]):
84+ def __aiter__ (self ) -> _T_co : ...
7985
8086class object :
8187 __doc__ : str | None
@@ -990,7 +996,7 @@ class _PathLike(Protocol[_AnyStr_co]):
990996 def __fspath__ (self ) -> _AnyStr_co : ...
991997
992998if sys .version_info >= (3 , 10 ):
993- def aiter (__async_iterable : AsyncIterable [ _T ]) -> AsyncIterator [ _T ] : ...
999+ def aiter (__async_iterable : _SupportsAiter [ _SupportsAnextT ]) -> _SupportsAnextT : ...
9941000 @overload
9951001 async def anext (__i : SupportsAnext [_T ]) -> _T : ...
9961002 @overload
@@ -1073,7 +1079,7 @@ def hex(__number: int | SupportsIndex) -> str: ...
10731079def id (__obj : object ) -> int : ...
10741080def input (__prompt : object = ...) -> str : ...
10751081@overload
1076- def iter (__iterable : Iterable [ _T ]) -> Iterator [ _T ] : ...
1082+ def iter (__iterable : _SupportsIter [ _SupportsNextT ]) -> _SupportsNextT : ...
10771083@overload
10781084def iter (__function : Callable [[], _T | None ], __sentinel : None ) -> Iterator [_T ]: ...
10791085@overload
0 commit comments