Title: Decorator on __init__ causes loss of type info · Issue #5398 · python/mypy · GitHub
Open Graph Title: Decorator on __init__ causes loss of type info · Issue #5398 · python/mypy
X Title: Decorator on __init__ causes loss of type info · Issue #5398 · python/mypy
Description: Here's a simple example: from __future__ import annotations from typing import Callable def decorator(method: Callable[[Foo], None]) -> Callable[[Foo], None]: return method class Foo(): @decorator def __init__(self): pass reveal_type(Foo...
Open Graph Description: Here's a simple example: from __future__ import annotations from typing import Callable def decorator(method: Callable[[Foo], None]) -> Callable[[Foo], None]: return method class Foo(): @decorator ...
X Description: Here's a simple example: from __future__ import annotations from typing import Callable def decorator(method: Callable[[Foo], None]) -> Callable[[Foo], None]: return method class Foo(): @dec...
Opengraph URL: https://github.com/python/mypy/issues/5398
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Decorator on __init__ causes loss of type info","articleBody":"Here's a simple example:\r\n\r\n```\r\nfrom __future__ import annotations\r\nfrom typing import Callable\r\n\r\ndef decorator(method: Callable[[Foo], None]) -> Callable[[Foo], None]:\r\n return method\r\n\r\nclass Foo():\r\n @decorator\r\n def __init__(self):\r\n pass\r\n\r\nreveal_type(Foo.__init__)\r\n```\r\n\r\nThe output of mypy is:\r\n\r\n```\r\n% mypy --version\r\nmypy 0.620\r\n% mypy foo.py\r\nfoo.py:13: error: Revealed type is 'Any'\r\n```\r\n\r\nThis seems to be specific to methods as similar type inferences work fine for functions outside of the class scope.","author":{"url":"https://github.com/campkeith","@type":"Person","name":"campkeith"},"datePublished":"2018-07-27T18:09:32Z","url":"https://github.com/python/mypy/issues/5398"}
| 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:dc99f403-19ec-ff74-9fdd-62b73946315b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8FB8:3D44CB:DA65A7:11E5134:6AFFFB86 |
| html-safe-nonce | a768318f11b3d9acb3a963e43af178c5b9258632336338b993e3c2fba91aa195 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RkI4OjNENDRDQjpEQTY1QTc6MTFFNTEzNDo2QUZGRkI4NiIsInZpc2l0b3JfaWQiOiIxMzA1MDA4NDQ1ODM3MDE1OTQyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 391381a333a6d02be7ab1656703399a3d05e885e89d03107cbbbe5b3e16dae9e |
| hovercard-subject-tag | issue:345318213 |
| 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/5398/issue_layout |
| twitter:image | https://opengraph.githubassets.com/17426449e1d465ea52b8329f642de4e89e1996413f287d1c6bf643893eae7065/python/mypy/issues/5398 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/17426449e1d465ea52b8329f642de4e89e1996413f287d1c6bf643893eae7065/python/mypy/issues/5398 |
| og:image:alt | Here's a simple example: from __future__ import annotations from typing import Callable def decorator(method: Callable[[Foo], None]) -> Callable[[Foo], None]: return method class Foo(): @decorator ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | campkeith |
| 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