Title: Generic decorators don't work with generic functions · Issue #1317 · python/mypy · GitHub
Open Graph Title: Generic decorators don't work with generic functions · Issue #1317 · python/mypy
X Title: Generic decorators don't work with generic functions · Issue #1317 · python/mypy
Description: UPDATE: Although the original example is now special-cased in a plugin, the underlying problem is not solved, see #1317 (comment) The following: from typing import * from contextlib import * T = TypeVar("T") @contextmanager def foo(x): #...
Open Graph Description: UPDATE: Although the original example is now special-cased in a plugin, the underlying problem is not solved, see #1317 (comment) The following: from typing import * from contextlib import * T = Ty...
X Description: UPDATE: Although the original example is now special-cased in a plugin, the underlying problem is not solved, see #1317 (comment) The following: from typing import * from contextlib import * T = Ty...
Opengraph URL: https://github.com/python/mypy/issues/1317
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Generic decorators don't work with generic functions","articleBody":"*UPDATE*: Although the original example is now special-cased in a plugin, the underlying problem is not solved, see https://github.com/python/mypy/issues/1317#issuecomment-341959279\r\n\r\nThe following:\r\n\r\n``` python\r\nfrom typing import *\r\nfrom contextlib import *\r\n\r\nT = TypeVar(\"T\")\r\n\r\n@contextmanager\r\ndef foo(x):\r\n # type: (T) -> Iterator[T]\r\n yield x\r\n\r\ny = 1\r\nwith foo(2) as f:\r\n y = f\r\n```\r\n\r\ngives this error:\r\n\r\n```\r\nerror: Incompatible types in assignment (expression has type \"T\", variable has type \"int\")\r\n```\r\n\r\nIt should recognize the input as an `int` which would lead to the output being an `int` as well, not a `T`. This is probably due to the way the `contextmanager` stub is defined in typeshed.\r\n","author":{"url":"https://github.com/AlexOnAPeak","@type":"Person","name":"AlexOnAPeak"},"datePublished":"2016-03-24T22:53:29Z","url":"https://github.com/python/mypy/issues/1317"}
| 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:c33b2f71-4e21-7471-b227-bc061e5328a4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8FC8:2148FB:1766146:1F73187:6AFFEB86 |
| html-safe-nonce | bb98046239f936e6cd365926a4f385dfbe245e610863c3f63ad20da5c0e37929 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RkM4OjIxNDhGQjoxNzY2MTQ2OjFGNzMxODc6NkFGRkVCODYiLCJ2aXNpdG9yX2lkIjoiNjU2MTQ3OTgxODMwNTU5NjI5NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cd90ac26552d83c2787b3cfc4cc77f10411ec0a1741329b1eaa99e10df505496 |
| hovercard-subject-tag | issue:143381880 |
| 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/1317/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3ea1ccaa094985841dcf07c56af83e8e32985da28b978e4bb5826a79573d519d/python/mypy/issues/1317 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3ea1ccaa094985841dcf07c56af83e8e32985da28b978e4bb5826a79573d519d/python/mypy/issues/1317 |
| og:image:alt | UPDATE: Although the original example is now special-cased in a plugin, the underlying problem is not solved, see #1317 (comment) The following: from typing import * from contextlib import * T = Ty... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AlexOnAPeak |
| 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 | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width