Title: Incompatible type when using `asynccontextmanager` and `ParamSpec` in generics. · Issue #12806 · python/mypy · GitHub
Open Graph Title: Incompatible type when using `asynccontextmanager` and `ParamSpec` in generics. · Issue #12806 · python/mypy
X Title: Incompatible type when using `asynccontextmanager` and `ParamSpec` in generics. · Issue #12806 · python/mypy
Description: Bug Report Usage of asynccontexmanager together with ParamSpec casues mypy errors. To Reproduce from contextlib import asynccontextmanager from dataclasses import dataclass from typing import ( AsyncContextManager, AsyncIterator, Callabl...
Open Graph Description: Bug Report Usage of asynccontexmanager together with ParamSpec casues mypy errors. To Reproduce from contextlib import asynccontextmanager from dataclasses import dataclass from typing import ( Asy...
X Description: Bug Report Usage of asynccontexmanager together with ParamSpec casues mypy errors. To Reproduce from contextlib import asynccontextmanager from dataclasses import dataclass from typing import ( Asy...
Opengraph URL: https://github.com/python/mypy/issues/12806
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incompatible type when using `asynccontextmanager` and `ParamSpec` in generics.","articleBody":"**Bug Report**\r\n\r\nUsage of `asynccontexmanager` together with `ParamSpec` casues `mypy` errors.\r\n\r\n**To Reproduce**\r\n```python\r\nfrom contextlib import asynccontextmanager\r\nfrom dataclasses import dataclass\r\nfrom typing import (\r\n AsyncContextManager,\r\n AsyncIterator,\r\n Callable,\r\n Generic,\r\n ParamSpec,\r\n TypeVar,\r\n)\r\n\r\n_Input = ParamSpec(\"_Input\")\r\n_Result = TypeVar(\"_Result\")\r\n\r\n\r\n@dataclass\r\nclass Foo(Generic[_Input, _Result]):\r\n func: Callable[_Input, AsyncContextManager[_Result]]\r\n\r\n @asynccontextmanager\r\n async def boo(\r\n self, *args: _Input.args, **kwargs: _Input.kwargs\r\n ) -> AsyncIterator[_Result]:\r\n async with self.func(*args, **kwargs) as fr:\r\n yield fr\r\n```\r\n\r\n**Actual Behavior**\r\n\r\nError:\r\n```\r\nerror: Argument 1 to \"asynccontextmanager\" has incompatible type \"Callable[[Arg(Foo[_Input, _Result], 'self'), **_Input], AsyncIterator[_Result]]\"; expected \"Callable[[Arg(Foo[_Input, _Result], 'self'), **_Input], AsyncIterator[_Result]]\"\r\n```\r\n\r\n**Environment**\r\n\r\nMypy version: 0.950\r\nPython version: 3.10.3\r\n","author":{"url":"https://github.com/matiuszka","@type":"Person","name":"matiuszka"},"datePublished":"2022-05-18T06:31:43Z","url":"https://github.com/python/mypy/issues/12806"}
| 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:37ebc5b6-3e66-62ef-e7a5-8099c6f8ab27 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B9D4:3430F7:61B934:833CC3:6B003453 |
| html-safe-nonce | 38195b11481a23cde3d57a93ed3c7f58f7ddf316845b99ee9b55a2ce92588387 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOUQ0OjM0MzBGNzo2MUI5MzQ6ODMzQ0MzOjZCMDAzNDUzIiwidmlzaXRvcl9pZCI6IjQxMTkzNDU0OTk5MjI4OTM2MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7bc65412fd610ee7a6c0e05ea38bb665a22964023f01b2ef8d39a54ba8c49dac |
| hovercard-subject-tag | issue:1239493738 |
| 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/12806/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bbe4633ad77acf1346125ab6f37348a0ae5fda3b1d2bc0a1389d4a66a15ff119/python/mypy/issues/12806 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bbe4633ad77acf1346125ab6f37348a0ae5fda3b1d2bc0a1389d4a66a15ff119/python/mypy/issues/12806 |
| og:image:alt | Bug Report Usage of asynccontexmanager together with ParamSpec casues mypy errors. To Reproduce from contextlib import asynccontextmanager from dataclasses import dataclass from typing import ( Asy... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | matiuszka |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width