Title: Failure when overriding an protocol attribute with a property in protocol subclass · Issue #13954 · python/mypy · GitHub
Open Graph Title: Failure when overriding an protocol attribute with a property in protocol subclass · Issue #13954 · python/mypy
X Title: Failure when overriding an protocol attribute with a property in protocol subclass · Issue #13954 · python/mypy
Description: Bug Report Unexpected typing failure when subclassing protocol. To Reproduce mypy --strict f.py f.py: import typing class B(typing.Protocol): field1: float class D(B): @property def field1(self) -> float: return 0 @field1.setter def fiel...
Open Graph Description: Bug Report Unexpected typing failure when subclassing protocol. To Reproduce mypy --strict f.py f.py: import typing class B(typing.Protocol): field1: float class D(B): @property def field1(self) ->...
X Description: Bug Report Unexpected typing failure when subclassing protocol. To Reproduce mypy --strict f.py f.py: import typing class B(typing.Protocol): field1: float class D(B): @property def field1(self) -&...
Opengraph URL: https://github.com/python/mypy/issues/13954
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Failure when overriding an protocol attribute with a property in protocol subclass","articleBody":"**Bug Report**\r\n\r\nUnexpected typing failure when subclassing protocol.\r\n\r\n**To Reproduce**\r\n\r\n```mypy --strict f.py```\r\n\r\n**`f.py`:**\r\n```\r\nimport typing\r\n\r\nclass B(typing.Protocol):\r\n field1: float\r\n\r\nclass D(B):\r\n @property\r\n def field1(self) -> float: return 0\r\n\r\n @field1.setter\r\n def field1(self, v: float) -> None: pass\r\n\r\nclass E:\r\n @property\r\n def field1(self) -> float: return 0\r\n\r\n @field1.setter\r\n def field1(self, v: float) -> None: pass\r\n```\r\n\r\n**Expected Behavior**\r\n\r\nBoth classes, `D` and `E`, should pass type checking.\r\n\r\n**Actual Behavior**\r\n\r\nThe `D` class fails type checking:\r\n\r\n```\r\nf.py:7: error: Signature of \"field1\" incompatible with supertype \"B\"\r\nf.py:8: error: Signature of \"field1\" incompatible with supertype \"B\"\r\nFound 2 errors in 1 file (checked 1 source file)\r\n```\r\n\r\n**Your Environment**\r\n\r\nMultiple environments.\r\n\r\n```\r\n% mypy --version\r\nmypy 0.982 (compiled: yes)\r\n```\r\n","author":{"url":"https://github.com/cmeyer","@type":"Person","name":"cmeyer"},"datePublished":"2022-10-27T23:56:00Z","url":"https://github.com/python/mypy/issues/13954"}
| 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:41676da1-3eaf-188c-196d-a4cf1bdfafe4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E26C:283776:5E356C:7E2013:6B00330E |
| html-safe-nonce | c4490890b7bd9eaf29ce366c2d260fea4e5eb35321afa34401ed80afd1ffe098 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjZDOjI4Mzc3Njo1RTM1NkM6N0UyMDEzOjZCMDAzMzBFIiwidmlzaXRvcl9pZCI6IjMxMDY3NDgzMTMxMzU3NTYwNDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 87c8f89b7334e343ecf9d212baf56d997ba2713d789e1a46b39db062b16e404b |
| hovercard-subject-tag | issue:1426392555 |
| 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/13954/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c4a96702f260514d026d2ac9762bd37fd590e1560eccc8bbed0ac1fdf77ffadf/python/mypy/issues/13954 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c4a96702f260514d026d2ac9762bd37fd590e1560eccc8bbed0ac1fdf77ffadf/python/mypy/issues/13954 |
| og:image:alt | Bug Report Unexpected typing failure when subclassing protocol. To Reproduce mypy --strict f.py f.py: import typing class B(typing.Protocol): field1: float class D(B): @property def field1(self) ->... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | cmeyer |
| 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