Title: Suggest making protocol attribute read-only if invariance causes conflict · Issue #6002 · python/mypy · GitHub
Open Graph Title: Suggest making protocol attribute read-only if invariance causes conflict · Issue #6002 · python/mypy
X Title: Suggest making protocol attribute read-only if invariance causes conflict · Issue #6002 · python/mypy
Description: If a concrete attribute has a narrower type than protocol attribute, mypy will complain (adapted from #5998): prog.py:59: error: Argument 1 to "f" has incompatible type "C"; expected "Proto" prog.py:59: note: Following member(s) of "C" h...
Open Graph Description: If a concrete attribute has a narrower type than protocol attribute, mypy will complain (adapted from #5998): prog.py:59: error: Argument 1 to "f" has incompatible type "C"; expected "Proto" prog.p...
X Description: If a concrete attribute has a narrower type than protocol attribute, mypy will complain (adapted from #5998): prog.py:59: error: Argument 1 to "f" has incompatible type "C"; exp...
Opengraph URL: https://github.com/python/mypy/issues/6002
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Suggest making protocol attribute read-only if invariance causes conflict","articleBody":"If a concrete attribute has a narrower type than protocol attribute, mypy will complain (adapted from #5998):\r\n\r\n```\r\nprog.py:59: error: Argument 1 to \"f\" has incompatible type \"C\"; expected \"Proto\"\r\nprog.py:59: note: Following member(s) of \"C\" have conflicts:\r\nprog.py:59: note: name: expected \"Optional[str]\", got \"str\"\r\n```\r\n\r\nIt could help if mypy would suggest making the protocol attribute read-only (property or final attribute), which is often the right thing to do. \r\n\r\nWe already generate a related suggestion to use a covariant collection type when using an invariant collection causes type incompatibility.","author":{"url":"https://github.com/JukkaL","@type":"Person","name":"JukkaL"},"datePublished":"2018-12-04T12:04:14Z","url":"https://github.com/python/mypy/issues/6002"}
| 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:46a5a06c-fd84-28c5-917f-5029912347ba |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BC5E:3EE8F1:FBD9B1:1495A0E:6AFFF8AD |
| html-safe-nonce | cc589b76cbf8112e3757654188d0b60effafc4023e815da8d08706acca6ce819 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQzVFOjNFRThGMTpGQkQ5QjE6MTQ5NUEwRTo2QUZGRjhBRCIsInZpc2l0b3JfaWQiOiI3MjY0NDQ1ODIxNTQwNjI4NjUzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e200d04625ba71daec0302756ccedadc26fa0a245d493d6afc1f4a2261bb1c8f |
| hovercard-subject-tag | issue:387254128 |
| 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/6002/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0c99047486a0ce66bfb78a9955f13dadc0133bd3dbcbdbb906dc4eb0feac8c0e/python/mypy/issues/6002 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0c99047486a0ce66bfb78a9955f13dadc0133bd3dbcbdbb906dc4eb0feac8c0e/python/mypy/issues/6002 |
| og:image:alt | If a concrete attribute has a narrower type than protocol attribute, mypy will complain (adapted from #5998): prog.py:59: error: Argument 1 to "f" has incompatible type "C"; expected "Proto" prog.p... |
| 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 | 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