Title: Return type of `asyncio.gather` with `*args` · Issue #11123 · python/typeshed · GitHub
Open Graph Title: Return type of `asyncio.gather` with `*args` · Issue #11123 · python/typeshed
X Title: Return type of `asyncio.gather` with `*args` · Issue #11123 · python/typeshed
Description: There are some related issues: #1550 #3243 #2652 And several questions on StackOverflow 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 cur...
Open Graph Description: There are some related issues: #1550 #3243 #2652 And several questions on StackOverflow But the problem is still the same. When a generator is passed to asyncio.gather, the expected return type sho...
X Description: There are some related issues: #1550 #3243 #2652 And several questions on StackOverflow But the problem is still the same. When a generator is passed to asyncio.gather, the expected return type sho...
Opengraph URL: https://github.com/python/typeshed/issues/11123
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Return type of `asyncio.gather` with `*args`","articleBody":"There are some related issues:\r\n* #1550\r\n* #3243\r\n* #2652\r\n* And several questions on StackOverflow\r\n\r\nBut 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\r\n\r\nExample code snippet:\r\n```python\r\nasync def fetch(url: str) -> str:\r\n pass # fetch logic\r\n\r\n\r\ndef analyze(responses: list[str]) -> int:\r\n pass # analyze logic that need all responses, maybe external library\r\n\r\n\r\nasync def create_report(urls: list[str]):\r\n responses = await asyncio.gather(*(\r\n fetch(url)\r\n for url in urls\r\n ))\r\n some_value = analyze(responses)\r\n # create report\r\n```\r\n\r\n\r\nI read tasks.pyi file, but a significant number of developers use `asyncio.gather(*[...])`. So this behavior should be reviewed\r\n\r\n> Although practicality beats purity\r\n> (c) [The Zen of Python](https://peps.python.org/pep-0020/#the-zen-of-python)\r\n","author":{"url":"https://github.com/abionics","@type":"Person","name":"abionics"},"datePublished":"2023-12-08T15:19:09Z","url":"https://github.com/python/typeshed/issues/11123"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5351f823-b51c-a3b6-3ea8-1d75255aa5b7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A29E:23FDF9:1EBB6FE:29D0EE4:6B001B2B |
| html-safe-nonce | c81b73bb012c5792b95ef2c469edae21c0e7344ef169c2e71c401abbb55f4441 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMjlFOjIzRkRGOToxRUJCNkZFOjI5RDBFRTQ6NkIwMDFCMkIiLCJ2aXNpdG9yX2lkIjoiNDQyNDUxNDc2NDI1Njg0NDU4NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5d8b7658b4ba765fd5d7a35826a1b64b1ec7811699eda1a0e91f036a4dddde47 |
| hovercard-subject-tag | issue:2032846740 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/typeshed/11123/issue_layout |
| twitter:image | https://opengraph.githubassets.com/35413b4fd80f089199d82559de5bdc76976a061cc458052a3433b2009446df23/python/typeshed/issues/11123 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/35413b4fd80f089199d82559de5bdc76976a061cc458052a3433b2009446df23/python/typeshed/issues/11123 |
| og:image:alt | There are some related issues: #1550 #3243 #2652 And several questions on StackOverflow But the problem is still the same. When a generator is passed to asyncio.gather, the expected return type sho... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | abionics |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typeshed git https://github.com/python/typeshed.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 31696383 |
| octolytics-dimension-repository_nwo | python/typeshed |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31696383 |
| octolytics-dimension-repository_network_root_nwo | python/typeshed |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width