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

Fix false negatives involving Unions and generators or coroutines #14224

Merged
merged 2 commits into from
Dec 1, 2022

Conversation

hauntsaninja
Copy link
Collaborator

Fixes #14223

@github-actions

This comment has been minimized.

Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good! Just one question about tests.

@@ -925,3 +925,21 @@ async def f() -> AsyncGenerator[int, None]:

[builtins fixtures/async_await.pyi]
[typing fixtures/typing-async.pyi]

[case testAwaitUnion]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this also fix type checking yield in generators? If yes, can you add a test case for this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it does, will do!

@hauntsaninja hauntsaninja changed the title Fix unexpected Any when awaiting a union Fix false negatives involving Unions and generators or coroutines Dec 1, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2022

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

Tanjun (https://github.com/FasterSpeeding/Tanjun)
- tanjun/dependencies/owners.py:173: error: Returning Any from function declared to return "bool"  [no-any-return]
- tanjun/dependencies/owners.py:183: error: Returning Any from function declared to return "bool"  [no-any-return]
- tanjun/clients.py:2313: error: Returning Any from function declared to return "Snowflake"  [no-any-return]

pandas (https://github.com/pandas-dev/pandas)
+ pandas/io/formats/format.py:1233: error: Incompatible types in "yield" (actual type "Union[str, WriteBuffer[str], StringIO]", expected type "Union[WriteBuffer[str], StringIO]")  [misc]

steam.py (https://github.com/Gobot1234/steam.py)
+ steam/state.py:1076: error: Incompatible types in assignment (expression has type "Union[GroupMember, None, ClanMember]", variable has type "Union[GroupMember, ClanMember]")  [assignment]
+ steam/ext/commands/bot.py:616: error: No return value expected  [return-value]

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

Successfully merging this pull request may close these issues.

@overload on async callables accepting and returning union types leads to type erasure
2 participants