Skip to content

Use async def instead of def ... -> Awaitable in typing #7105

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

Merged
merged 2 commits into from
Feb 2, 2022
Merged

Use async def instead of def ... -> Awaitable in typing #7105

merged 2 commits into from
Feb 2, 2022

Conversation

sobolevn
Copy link
Member

@sobolevn sobolevn commented Feb 2, 2022

Source: https://github.com/python/cpython/blob/187930f74c44e460ba09c60ba5d9bb4fac543d8f/Lib/_collections_abc.py#L206-L240

Why is that important? Because async def is a Coroutine, which is much more than Awaitable. For example, this backfires in #6779

@sobolevn sobolevn mentioned this pull request Feb 2, 2022
@sobolevn
Copy link
Member Author

sobolevn commented Feb 2, 2022

Ok, types.pyi as well.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2022

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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants