Title: Reject covariant overriding of attributes · Issue #3208 · python/mypy · GitHub
Open Graph Title: Reject covariant overriding of attributes · Issue #3208 · python/mypy
X Title: Reject covariant overriding of attributes · Issue #3208 · python/mypy
Description: Covariant overriding of attributes is allowed though it's clearly unsafe. Example: class A: x: float class B(A): x: int # no error, though unsafe def f(a: A) -> None: a.x = 1.1 b = B() f(b) b.x # float at runtime, though declared as int ...
Open Graph Description: Covariant overriding of attributes is allowed though it's clearly unsafe. Example: class A: x: float class B(A): x: int # no error, though unsafe def f(a: A) -> None: a.x = 1.1 b = B() f(b) b.x # f...
X Description: Covariant overriding of attributes is allowed though it's clearly unsafe. Example: class A: x: float class B(A): x: int # no error, though unsafe def f(a: A) -> None: a.x = 1.1 b = B() f(b) ...
Opengraph URL: https://github.com/python/mypy/issues/3208
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Reject covariant overriding of attributes","articleBody":"Covariant overriding of attributes is allowed though it's clearly unsafe. Example:\r\n```py\r\nclass A:\r\n x: float\r\n\r\nclass B(A):\r\n x: int # no error, though unsafe\r\n\r\ndef f(a: A) -> None:\r\n a.x = 1.1\r\n\r\nb = B()\r\nf(b)\r\nb.x # float at runtime, though declared as int\r\n```\r\n\r\nMypy should reject `x: int` in `B`. If this is actually what the programmer intended, they can use `# type: ignore`.","author":{"url":"https://github.com/JukkaL","@type":"Person","name":"JukkaL"},"datePublished":"2017-04-21T10:59:02Z","url":"https://github.com/python/mypy/issues/3208"}
| 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:1444f04a-13f6-a70f-7516-4a66d0aa7271 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8CF4:C44F1:17E450:1E8012:6AFF91E9 |
| html-safe-nonce | 25bb57509367ca3798d5d613357ab2aaa4deaf99abc170bc44f8f7d9da21b023 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Q0Y0OkM0NEYxOjE3RTQ1MDoxRTgwMTI6NkFGRjkxRTkiLCJ2aXNpdG9yX2lkIjoiMzczMTYwODY0Mzg3NTg2OTE2MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ef7ed8f9221645e713955399b05581eca7e2d57f99f2f094bc8238c371317f0c |
| hovercard-subject-tag | issue:223350531 |
| 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/3208/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d583afc0bcbb6cefe786c9d32bba98d5c5bd58d5721f523786646921b624da0c/python/mypy/issues/3208 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d583afc0bcbb6cefe786c9d32bba98d5c5bd58d5721f523786646921b624da0c/python/mypy/issues/3208 |
| og:image:alt | Covariant overriding of attributes is allowed though it's clearly unsafe. Example: class A: x: float class B(A): x: int # no error, though unsafe def f(a: A) -> None: a.x = 1.1 b = B() f(b) b.x # f... |
| 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 | 2c75d045e8c84b51e2ac680086a6dd1eeaf2bc15b82137d22ee5106835d6256c |
| 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 | aa486b0389431f870c0adf9d4758aaff807c2d97 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width