Skip to content

Infer Coroutine for unannotated async defs#21651

Open
97littleleaf11 wants to merge 1 commit into
python:masterfrom
97littleleaf11:fix-12776
Open

Infer Coroutine for unannotated async defs#21651
97littleleaf11 wants to merge 1 commit into
python:masterfrom
97littleleaf11:fix-12776

Conversation

@97littleleaf11

Copy link
Copy Markdown
Collaborator

Fixes #12776
Add an extra check for unannotated async defs when checking function type. async def foo() is now treated like async def foo() -> Any

@github-actions

Copy link
Copy Markdown
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]

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.

Unannotated async function should be inferred as Awaitable[Any]

1 participant