You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But the problem is still the same. When a generator is passed to asyncio.gather, the expected return type should be Future[list[_T]]. However, it currently returns Future[tuple[_T1]], leading to type hinting warnings. This is a common pattern in asyncio code, and every time it cause unnecessary warnings in IDEs
Example code snippet:
asyncdeffetch(url: str) ->str:
pass# fetch logicdefanalyze(responses: list[str]) ->int:
pass# analyze logic that need all responses, maybe external libraryasyncdefcreate_report(urls: list[str]):
responses=awaitasyncio.gather(*(
fetch(url)
forurlinurls
))
some_value=analyze(responses)
# create report
I read tasks.pyi file, but a significant number of developers use asyncio.gather(*[...]). So this behavior should be reviewed
I use PyCharm's built-in type checker. I run mypy and pyright type checkers on this code snippet and both return 0 errors. So it must be bug in PyCharm
@JelleZijlstra thank you! Your question was the answer :) I think you can close this issue
There are some related issues:
But the problem is still the same. When a generator is passed to
asyncio.gather
, the expected return type should beFuture[list[_T]]
. However, it currently returnsFuture[tuple[_T1]]
, leading to type hinting warnings. This is a common pattern in asyncio code, and every time it cause unnecessary warnings in IDEsExample code snippet:
I read tasks.pyi file, but a significant number of developers use
asyncio.gather(*[...])
. So this behavior should be reviewedThe text was updated successfully, but these errors were encountered: