Skip to content
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

Propagate is_async_generator down to overloads #17435

Closed

Conversation

sterliakov
Copy link
Contributor

Closes #17340

When an overloaded definition is checked, overloads usually have a trivial body. As a result, the return type of async overloads is wrapped with Coroutine, while the implementation is not - all this happens during semanal based solely on yield presence.

When such situation is encountered, we should unwrap the return type and mark the functions as async generators.

@sterliakov sterliakov marked this pull request as draft June 24, 2024 22:31

This comment has been minimized.

Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

steam.py (https://github.com/Gobot1234/steam.py)
- steam/leaderboard.py:114: error: Overloaded function implementation cannot produce return type of signature 1  [misc]
- steam/leaderboard.py:114: error: Overloaded function implementation cannot produce return type of signature 2  [misc]

@sterliakov
Copy link
Contributor Author

Primer diff shows only one false positive removed. That error was caused exactly by mistreatment fixed in this PR.

@sterliakov sterliakov marked this pull request as ready for review June 24, 2024 23:29
@hauntsaninja
Copy link
Collaborator

Thanks for the PR! Since this changes the meanings of annotations, we should probably open a thread on https://discuss.python.org/c/typing/32 (e.g. pyright currently behaves the same as mypy)

@sterliakov
Copy link
Contributor Author

@sterliakov
Copy link
Contributor Author

I'm marking this draft for now, because Eric Traut seems to be against this idea, let's wait for some decision to settle.

@hauntsaninja
Copy link
Collaborator

Closing as per the discuss thread. Efforts in this direction should go via changes to the typing spec

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.

@overload doesn't work with @asynccontextmanager
2 participants