-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Clarification: return type for asyncio.gather()? #3243
Comments
I assume it's done like this in the stubs, because typing's type system only allows x, y, z = await gather(foo(), bar(), baz()) Where But this should at least be documented in the stubs. |
@srittau Yes, the iterable unpacking portion of that code makes sense but, in my own view, this is a bit like calling the sky orange 😉 Looking back though, PR #1550 discussed this specifically, followed by c5f1e90. So if we agree in something, it's that it could be documented a bit more clearly in case, for instance, someone tries to call |
Stems from PR python#1550/ Issue python#3243.
That solved this error for me
|
I've come across a source of confusion for
asyncio.gather()
. It may very well be user error rather than an incorrect annotation. (Motivated by this Stack Overflow post.)The annotation return types for
gather()
areFuture[Tuple[_T1]]
,Future[Tuple[_T1, _T2]]
, and so on.However, the result of
return await asyncio.gather(*tasks)
isList
. I.e.:This runs find, printing
[1, 2, 3]
;await asyncio.gather()
produces aList[int]
.However, mypy complains that:
Why does this ambiguity exist? How can I provide a correct type hint for
async def main()
?I'm looking at typeshed master branch as of 0602840 fyi + mypy 0.720.
The text was updated successfully, but these errors were encountered: