-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
AsyncIterator.__anext__ can be any Awaitable object #7475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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