Skip to content

Update pythoneval-asyncio.test - #11908

Merged
hauntsaninja merged 1 commit into
python:masterfrom
sobolevn:patch-20
Jan 5, 2022
Merged

Update pythoneval-asyncio.test#11908
hauntsaninja merged 1 commit into
python:masterfrom
sobolevn:patch-20

Conversation

@sobolevn

Copy link
Copy Markdown
Member

@hauntsaninja

Copy link
Copy Markdown
Collaborator

Thanks, you're right that this one doesn't need to be done in the sync PR since it'll pass on master

@sobolevnsobolevn mentioned this pull request Jan 5, 2022
@sobolevn

Copy link
Copy Markdown
MemberAuthor

@hauntsaninja is there anything else I should do? 🙂

@hauntsaninja

Copy link
Copy Markdown
Collaborator

Nope, this one was straightforward and I had covered. If you want, you could look into what's going on with type inference in testAsyncioGatherPreciseType in the "Sync typeshed" PR, but feel free not to!

@hauntsaninja
hauntsaninja merged commit edbc248 into python:masterJan 5, 2022
@sobolevn

sobolevn commented Jan 6, 2022

Copy link
Copy Markdown
MemberAuthor

@hauntsaninja it looks like this happens because gather uses tuple and list as return types. Overload logic does not like this, here:

inferred_result=self.infer_overload_return_type(plausible_targets, args, arg_types,

So, the common return type is infered there as Future[Any].

importasyncioreveal_type(asyncio.gather)
reveal_type(asyncio.gather(*[asyncio.sleep(1), asyncio.sleep(1)]))

Stub for gather (simplified):

@overloaddefgather(*coros_or_futures: _FutureT[Any], return_exceptions: bool= ...) ->Future[list[Any]]: ...
@overloaddefgather(__coro_or_future1: _FutureT[_T1], *, return_exceptions: Literal[False] = ...) ->Future[tuple[T1]]: ...
[def (*coros_or_futures: Union[asyncio.futures.Future[Any], typing.Generator[Any, None, Any], typing.Awaitable[Any]], *, return_exceptions: builtins.bool =) -> asyncio.futures.Future[builtins.list[Any]], def [_T1] (Union[asyncio.futures.Future[_T1`-1], typing.Generator[Any, None, _T1`-1], typing.Awaitable[_T1`-1]], *, return_exceptions: Literal[False] =) -> asyncio.futures.Future[builtins.int]]
(asyncio.futures.Future[Any], def (*Any, **Any) -> Any)
out/ex.py:3: note: Revealed type is "Overload(def (*coros_or_futures: Union[asyncio.futures.Future[Any], typing.Generator[Any, None, Any], typing.Awaitable[Any]], *, return_exceptions: builtins.bool =) -> asyncio.futures.Future[builtins.list[Any]], def [_T1] (Union[asyncio.futures.Future[_T1`-1], typing.Generator[Any, None, _T1`-1], typing.Awaitable[_T1`-1]], *, return_exceptions: Literal[False] =) -> asyncio.futures.Future[builtins.int])"

@hauntsaninja

hauntsaninja commented Jan 6, 2022

Copy link
Copy Markdown
Collaborator

@sobolevn but the type of asyncio.gather has not changed in #11905 , only the type of asyncio.sleep has

https://github.com/python/mypy/pull/11905/files#diff-04a6e8e72f5ccf748662e8786571059eccb8154c46a42135c26127862e756870

tushar-deepsource pushed a commit to DeepSourceCorp/mypy that referenced this pull request Jan 20, 2022
Sign up for freeto 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

@sobolevn@hauntsaninja