Title: Decorated method type-incompatibility with superclass · Issue #5836 · python/mypy · GitHub
Open Graph Title: Decorated method type-incompatibility with superclass · Issue #5836 · python/mypy
X Title: Decorated method type-incompatibility with superclass · Issue #5836 · python/mypy
Description: I'm raising a bug. It's also posted on SO at https://stackoverflow.com/q/52744713/5986907 I get $ mypy file.py python.py:34: error: Signature of "fn" incompatible with supertype "B" for file.py from typing import Callable, TypeVar, cast ...
Open Graph Description: I'm raising a bug. It's also posted on SO at https://stackoverflow.com/q/52744713/5986907 I get $ mypy file.py python.py:34: error: Signature of "fn" incompatible with supertype "B" for file.py fro...
X Description: I'm raising a bug. It's also posted on SO at https://stackoverflow.com/q/52744713/5986907 I get $ mypy file.py python.py:34: error: Signature of "fn" incompatible with supertype &...
Opengraph URL: https://github.com/python/mypy/issues/5836
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Decorated method type-incompatibility with superclass","articleBody":"I'm raising a bug.\r\n\r\nIt's also posted on SO at https://stackoverflow.com/q/52744713/5986907\r\n\r\nI get \r\n\r\n $ mypy file.py\r\n python.py:34: error: Signature of \"fn\" incompatible with supertype \"B\"\r\n\r\nfor file.py\r\n\r\n from typing import Callable, TypeVar, cast\r\n\r\n T = TypeVar('T')\r\n\r\n\r\n def dec(f: Callable[..., T]) -> T:\r\n def p(self):\r\n return getattr(self, '_' + f.__name__)\r\n\r\n return cast(T, property(p))\r\n\r\n\r\n class X:\r\n pass\r\n\r\n\r\n class Y(X):\r\n pass\r\n\r\n\r\n class A:\r\n _fn = Y()\r\n\r\n\r\n class B(A):\r\n @dec\r\n def fn(self) -> X:\r\n return X()\r\n\r\n\r\n class C(B):\r\n @dec\r\n def fn(self) -> Y:\r\n return Y()\r\n\r\n\r\nI'd expect there to be no error as Y is a subclass of X.\r\n\r\nI've tried this with mypy 0.630 and Python 3.5.2, 3.6.6 and 3.7.0. Also with mypy git master for python 3.5.2 and 3.7.0\r\n\r\nIt's possible these are related but I couldn't quite connect them\r\nhttps://github.com/python/mypy/issues/220\r\nhttps://github.com/python/mypy/issues/4430","author":{"url":"https://github.com/joelberkeley","@type":"Person","name":"joelberkeley"},"datePublished":"2018-10-25T13:58:57Z","url":"https://github.com/python/mypy/issues/5836"}
| 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:ee371f73-f034-e159-2a13-d2954fa1c8a8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A714:160A87:CE0D3B:10D31CD:6AFFF668 |
| html-safe-nonce | c4d2cf416233aad0d317b7c256de3aff6d7c6883664067b0f9157881d7c8d380 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNzE0OjE2MEE4NzpDRTBEM0I6MTBEMzFDRDo2QUZGRjY2OCIsInZpc2l0b3JfaWQiOiIyMTgzNDYyNjkyODg5NTM0NDgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 51288fa2a8aac7a7fdb7fd855f4d4af42553b6daae27a39ebe98a1b678942c80 |
| hovercard-subject-tag | issue:373962078 |
| 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/5836/issue_layout |
| twitter:image | https://opengraph.githubassets.com/56d87c44a73a0bc8ebf753ed546f16f15f57b01126a61fb6300e8c3bcd5cce70/python/mypy/issues/5836 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/56d87c44a73a0bc8ebf753ed546f16f15f57b01126a61fb6300e8c3bcd5cce70/python/mypy/issues/5836 |
| og:image:alt | I'm raising a bug. It's also posted on SO at https://stackoverflow.com/q/52744713/5986907 I get $ mypy file.py python.py:34: error: Signature of "fn" incompatible with supertype "B" for file.py fro... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | joelberkeley |
| 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