Title: ParamSpec + Generics false positive · Issue #14347 · python/mypy · GitHub
Open Graph Title: ParamSpec + Generics false positive · Issue #14347 · python/mypy
X Title: ParamSpec + Generics false positive · Issue #14347 · python/mypy
Description: Bug Report Hello. Here's something I stumbled upon implementing an asyncio thing. It looks like an issue with ParamSpec and/or generics to me. To Reproduce from asyncio import AbstractEventLoop, Task, get_running_loop from contextvars im...
Open Graph Description: Bug Report Hello. Here's something I stumbled upon implementing an asyncio thing. It looks like an issue with ParamSpec and/or generics to me. To Reproduce from asyncio import AbstractEventLoop, Ta...
X Description: Bug Report Hello. Here's something I stumbled upon implementing an asyncio thing. It looks like an issue with ParamSpec and/or generics to me. To Reproduce from asyncio import AbstractEventLoop...
Opengraph URL: https://github.com/python/mypy/issues/14347
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ParamSpec + Generics false positive","articleBody":"**Bug Report**\r\n\r\nHello. Here's something I stumbled upon implementing an asyncio thing. It looks like an issue with ParamSpec and/or generics to me.\r\n\r\n**To Reproduce**\r\n\r\n```python\r\nfrom asyncio import AbstractEventLoop, Task, get_running_loop\r\nfrom contextvars import copy_context\r\n\r\n\r\nloop: AbstractEventLoop = get_running_loop()\r\n\r\n\r\nasync def to_run() -> int:\r\n return 1\r\n\r\n\r\ntask: Task[int]\r\n\r\n# Works, correctly:\r\ntask = loop.create_task(to_run())\r\n\r\n# Error, incorrectly:\r\ntask = copy_context().run(loop.create_task, to_run())\r\n```\r\n\r\n**Expected Behavior**\r\n\r\nThe example should type-check.\r\n\r\n**Actual Behavior**\r\n\r\nMypy reports the following:\r\n\r\n```\r\na02.py:18: error: Argument 1 to \"run\" of \"Context\" has incompatible type \"Callable[[Union[Coroutine[Any, Any, _T], Generator[Any, None, _T]], DefaultNamedArg(Optional[str], 'name'), DefaultNamedArg(Optional[Context], 'context')], Task[_T]]\"; expected \"Callable[[Union[Coroutine[Any, Any, _T], Generator[Any, None, _T]], DefaultNamedArg(Optional[str], 'name'), DefaultNamedArg(Optional[Context], 'context')], Task[int]]\" [arg-type]\r\na02.py:18: error: Argument 2 to \"run\" of \"Context\" has incompatible type \"Coroutine[Any, Any, int]\"; expected \"Union[Coroutine[Any, Any, _T], Generator[Any, None, _T]]\" [arg-type]\r\nFound 2 errors in 1 file (checked 1 source file)\r\n```\r\n\r\n**Your Environment**\r\n\r\n\u003c!-- Include as many relevant details about the environment you experienced the bug in -->\r\n\r\n- Mypy version used: mypy 0.991 (compiled: yes)\r\n- Mypy command-line flags:\r\n- Mypy configuration options from `mypy.ini` (and other config files):\r\n- Python version used: 3.11.1","author":{"url":"https://github.com/Tinche","@type":"Person","name":"Tinche"},"datePublished":"2022-12-26T16:57:29Z","url":"https://github.com/python/mypy/issues/14347"}
| 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:28c031b6-6b30-ee71-bb4a-a652606dbfa3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9DC2:2B3CBD:C5180C:10055B5:6AFFF19D |
| html-safe-nonce | b9fa18ad9720ab010df59362ef68c4a02b10f73f4fb9e8e7098ed0a34c28f732 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5REMyOjJCM0NCRDpDNTE4MEM6MTAwNTVCNTo2QUZGRjE5RCIsInZpc2l0b3JfaWQiOiI2NzcwOTQxNjc1MzY0Njc1OTk3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | d493d07a3279cc5f090c04632008615ab4a656febab22a5441b45fd12d2829f1 |
| hovercard-subject-tag | issue:1511084513 |
| 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/mypy/14347/issue_layout |
| twitter:image | https://opengraph.githubassets.com/083903797c66075ab73fd6f6ae91869cb1fb5aab0923ed246f8278e5993167aa/python/mypy/issues/14347 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/083903797c66075ab73fd6f6ae91869cb1fb5aab0923ed246f8278e5993167aa/python/mypy/issues/14347 |
| og:image:alt | Bug Report Hello. Here's something I stumbled upon implementing an asyncio thing. It looks like an issue with ParamSpec and/or generics to me. To Reproduce from asyncio import AbstractEventLoop, Ta... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Tinche |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| 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 | 16a11879678aaf97e2a42c33ee70830aa084fa37 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width