Title: Forward reference to decorated class method has type Any · Issue #4485 · python/mypy · GitHub
Open Graph Title: Forward reference to decorated class method has type Any · Issue #4485 · python/mypy
X Title: Forward reference to decorated class method has type Any · Issue #4485 · python/mypy
Description: In the program below, the type inferred for cls.g in A.f is Any, even though it should be def (x: builtins.str): from typing import TypeVar, Callable T = TypeVar('T') def dec() -> Callable[[T], T]: pass class A: @classmethod def f(cls) -...
Open Graph Description: In the program below, the type inferred for cls.g in A.f is Any, even though it should be def (x: builtins.str): from typing import TypeVar, Callable T = TypeVar('T') def dec() -> Callable[[T], T]:...
X Description: In the program below, the type inferred for cls.g in A.f is Any, even though it should be def (x: builtins.str): from typing import TypeVar, Callable T = TypeVar('T') def dec() -> Callab...
Opengraph URL: https://github.com/python/mypy/issues/4485
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Forward reference to decorated class method has type Any","articleBody":"In the program below, the type inferred for `cls.g` in `A.f` is `Any`, even though it should be `def (x: builtins.str)`:\r\n\r\n\r\n```py\r\nfrom typing import TypeVar, Callable\r\n\r\nT = TypeVar('T')\r\ndef dec() -> Callable[[T], T]: pass\r\n\r\nclass A:\r\n @classmethod\r\n def f(cls) -> None:\r\n reveal_type(cls.g) # Any \u003c-- unexpected\r\n\r\n @classmethod\r\n @dec()\r\n def g(cls, x: str) -> None:\r\n pass\r\n\r\n @classmethod\r\n def h(cls) -> None:\r\n reveal_type(cls.g) # def (x: builtins.str) \u003c-- ok\r\n```\r\n\r\nThis works correctly when the decorated method is accessed using an instance type (such as `self`).\r\n\r\nIn fine-grained incremental mode the types can be more precise, which can result in additional errors in fine-grained incremental mode.","author":{"url":"https://github.com/JukkaL","@type":"Person","name":"JukkaL"},"datePublished":"2018-01-18T11:54:01Z","url":"https://github.com/python/mypy/issues/4485"}
| 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:fcda3611-9e22-6588-0b96-f16eb2801f59 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8ECA:22F32B:CB304:11E2DB:6B00633D |
| html-safe-nonce | 7467fe4704c0b459a7236b65d08673ccae0ce4783cc0684128da3e779f880119 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RUNBOjIyRjMyQjpDQjMwNDoxMUUyREI6NkIwMDYzM0QiLCJ2aXNpdG9yX2lkIjoiMzQ5Mjk1ODk1Nzg3MjM3NDU4OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1cca2f4a1087fb77fa13c5e0fe0d93356ad3ae8fe02746c9c081499934f40a23 |
| hovercard-subject-tag | issue:289602331 |
| 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/4485/issue_layout |
| twitter:image | https://opengraph.githubassets.com/be10d2a227e5b74ecbcf273f49a95682ff04e8a30e32e5559a6295a3b0cbdd77/python/mypy/issues/4485 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/be10d2a227e5b74ecbcf273f49a95682ff04e8a30e32e5559a6295a3b0cbdd77/python/mypy/issues/4485 |
| og:image:alt | In the program below, the type inferred for cls.g in A.f is Any, even though it should be def (x: builtins.str): from typing import TypeVar, Callable T = TypeVar('T') def dec() -> Callable[[T], T]:... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JukkaL |
| hostname | github.com |
| expected-hostname | github.com |
| None | 25854482a1773a7c1ebb8be3d2bc1c6e61d82d78126be63b5044474a86d44d9e |
| 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 | e4f5c239e31f1f680e6bbc419ff92d774da616ec |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width