Infer Coroutine for unannotated async defs#21651
Open
97littleleaf11 wants to merge 1 commit into
Open
Conversation
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: psycopg (https://github.com/psycopg/psycopg)
+ tests/pool/test_pool_async.py:543: error: All conditional function variants must have identical signatures [misc]
+ tests/pool/test_pool_async.py:543: note: Original:
+ tests/pool/test_pool_async.py:543: note: def failed(pool: Any) -> Coroutine[Any, Any, Any]
+ tests/pool/test_pool_async.py:543: note: Redefinition:
+ tests/pool/test_pool_async.py:543: note: def failed(pool: Any) -> Any
aioredis (https://github.com/aio-libs/aioredis)
+ aioredis/client.py:1697: error: Value of type "Coroutine[Any, Any, Any]" must be used [unused-coroutine]
+ aioredis/client.py:1697: note: Are you missing an await?
+ aioredis/client.py:4426: error: Return type "Pipeline | Awaitable[Pipeline]" of "execute_command" incompatible with return type "Coroutine[Any, Any, Any]" in supertype "Redis" [override]
discord.py (https://github.com/Rapptz/discord.py)
+ discord/member.py:199: error: All conditional function variants must have identical signatures [misc]
+ discord/member.py:199: note: Original:
+ discord/member.py:199: note: def general(self: Any, *args: Any, **kwargs: Any) -> Coroutine[Any, Any, Any]
+ discord/member.py:199: note: Redefinition:
+ discord/member.py:199: note: def general(self: Any, *args: Any, **kwargs: Any) -> Any
tornado (https://github.com/tornadoweb/tornado)
+ tornado/test/asyncio_test.py:90: error: Argument 1 to "to_asyncio_future" has incompatible type "Coroutine[Any, Any, Any]"; expected "Future[Any]" [arg-type]
graphql-core (https://github.com/graphql-python/graphql-core)
+ tests/utils/assert_equal_awaitables_or_values.py:26: error: Incompatible return value type (got "Coroutine[Any, Any, Any]", expected "T") [return-value]
+ tests/execution/test_stream.py:1699: error: Incompatible types in assignment (expression has type "str", variable has type "Coroutine[Any, Any, Any]") [assignment]
+ tests/execution/test_stream.py:1765: error: Incompatible types in assignment (expression has type "str", variable has type "Coroutine[Any, Any, Any]") [assignment]
+ tests/execution/test_abstract.py:61: error: All conditional function variants must have identical signatures [misc]
+ tests/execution/test_abstract.py:61: note: Original:
+ tests/execution/test_abstract.py:61: note: def is_type_of(obj: Any, _info: Any) -> Any
+ tests/execution/test_abstract.py:61: note: Redefinition:
+ tests/execution/test_abstract.py:61: note: def is_type_of(obj: Any, _info: Any) -> Coroutine[Any, Any, Any]
+ tests/execution/test_abstract.py:77: error: All conditional function variants must have identical signatures [misc]
+ tests/execution/test_abstract.py:77: note: Original:
+ tests/execution/test_abstract.py:77: note: def type_error(*_args: Any) -> Any
+ tests/execution/test_abstract.py:77: note: Redefinition:
+ tests/execution/test_abstract.py:77: note: def type_error(*_args: Any) -> Coroutine[Any, Any, Any]
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #12776
Add an extra check for unannotated async defs when checking function type.
async def foo()is now treated likeasync def foo() -> Any