mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-22 11:51:28 +08:00
Return coroutine from AsyncGenerator.__anext__ (#12685)
The `__anext__` method of an asynchronous generator defined using the `async def`/`yield` syntax returns an actual coroutine not just any awaitable. Let the definition of the `AsyncGenerator` protocol reflect this circumstance. See https://discuss.python.org/t/types-for-asynchronous-generators-too-general/64515 for the motivation behind this change.
This commit is contained in:
committed by
GitHub
parent
bde71c575f
commit
46512118ea
@@ -540,7 +540,7 @@ class AsyncIterator(AsyncIterable[_T_co], Protocol[_T_co]):
|
||||
def __aiter__(self) -> AsyncIterator[_T_co]: ...
|
||||
|
||||
class AsyncGenerator(AsyncIterator[_YieldT_co], Generic[_YieldT_co, _SendT_contra]):
|
||||
def __anext__(self) -> Awaitable[_YieldT_co]: ...
|
||||
def __anext__(self) -> Coroutine[Any, Any, _YieldT_co]: ...
|
||||
@abstractmethod
|
||||
def asend(self, value: _SendT_contra, /) -> Coroutine[Any, Any, _YieldT_co]: ...
|
||||
@overload
|
||||
|
||||
Reference in New Issue
Block a user