AsyncIterator.__anext__ can be any Awaitable object#7475
AsyncIterator.__anext__ can be any Awaitable object#7475graingert wants to merge 1 commit intopython:masterfrom
Conversation
|
I think this also applies to AsyncGenerator |
|
Diff from mypy_primer, showing the effect of this PR on open source code: tornado (https://github.com/tornadoweb/tornado)
- tornado/gen.py:429: error: Incompatible return value type (got "WaitIterator", expected "AsyncIterator[Any]")
- tornado/gen.py:429: note: Following member(s) of "WaitIterator" have conflicts:
- tornado/gen.py:429: note: Expected:
- tornado/gen.py:429: note: def __anext__(self) -> Coroutine[Any, Any, Any]
- tornado/gen.py:429: note: Got:
- tornado/gen.py:429: note: def __anext__(self) -> Future[Any]
boostedblob (https://github.com/hauntsaninja/boostedblob)
+ boostedblob/boost.py:547: error: Need type annotation for "task"
+ boostedblob/boost.py:547: error: Argument 1 to "create_task" has incompatible type "Awaitable[T]"; expected "Union[Generator[Any, None, <nothing>], Coroutine[Any, Any, <nothing>]]"
|
|
Yep they're all specified as returning Awaitable: https://peps.python.org/pep-0525/#asynchronous-generator-object I think this PR needs reverting #7105 |
Yes, I think that's probably right. stubtest is complaining because these are all |
|
It would be nice if "real" |
Not sure I understand, sorry |
|
I've proposed a slightly larger PR here: #7491. Would appreciate your thoughts! |
Oh this already exists as |
|
Closing in favour of #7491 |
https://peps.python.org/pep-0525/#support-for-asynchronous-iteration-protocol