Title: final TypedDict · Issue #7981 · python/mypy · GitHub
Open Graph Title: final TypedDict · Issue #7981 · python/mypy
X Title: final TypedDict · Issue #7981 · python/mypy
Description: Reopened from #7845 as requested mypy seems to ignore the @final decorator when it is applied to a TypedDict. This issue becomes material when one invokes the items() or values() methods, or passes a generic string to get(); then the out...
Open Graph Description: Reopened from #7845 as requested mypy seems to ignore the @final decorator when it is applied to a TypedDict. This issue becomes material when one invokes the items() or values() methods, or passes...
X Description: Reopened from #7845 as requested mypy seems to ignore the @final decorator when it is applied to a TypedDict. This issue becomes material when one invokes the items() or values() methods, or passes...
Opengraph URL: https://github.com/python/mypy/issues/7981
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"final TypedDict","articleBody":"Reopened from #7845 as requested\r\n\r\nmypy seems to ignore the ``@final`` decorator when it is applied to a TypedDict. This issue becomes material when one invokes the items() or values() methods, or passes a generic string to get(); then the output will be incorrectly upcast to object since mypy thinks it may be dealing with a subclass.\r\n\r\n```python\r\nfrom typing_extensions import final, TypedDict\r\n\r\n@final\r\nclass Point(TypedDict):\r\n x: float\r\n y: float\r\n z: float\r\n\r\n\r\np: Point\r\nx: str\r\nreveal_type(p.values())\r\nreveal_type(p.items())\r\nreveal_type(p.get(x, 0.0))\r\n\r\n```\r\nOutput:\r\n```\r\n12: note: Revealed type is 'typing.ValuesView[builtins.object*]'\r\n13: note: Revealed type is 'typing.AbstractSet[Tuple[builtins.str*, builtins.object*]]'\r\n14: note: Revealed type is 'builtins.object*'\r\n```\r\nExpected output:\r\n```\r\n12: note: Revealed type is 'typing.ValuesView[builtins.float*]'\r\n13: note: Revealed type is 'typing.ItemsView[builtins.str*, builtins.float*]'\r\n14: note: Revealed type is 'builtins.float*'\r\n```","author":{"url":"https://github.com/crusaderky","@type":"Person","name":"crusaderky"},"datePublished":"2019-11-20T10:06:14Z","url":"https://github.com/python/mypy/issues/7981"}
| 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:76d87b74-71c7-d475-fed0-2e7d6a64076b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8CFE:2A0045:330919E:4394AED:6B003855 |
| html-safe-nonce | 0917a589f2733492a276386ec39b8343fd96777de0c7b484a7a109a8144e232d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Q0ZFOjJBMDA0NTozMzA5MTlFOjQzOTRBRUQ6NkIwMDM4NTUiLCJ2aXNpdG9yX2lkIjoiODI2NTM0MzI2OTMyODY2NDY2MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 20a6b97798c6adfc4609f492528523ed4f9950107dc04325dec96c9e7b919710 |
| hovercard-subject-tag | issue:525700041 |
| 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/7981/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6b067edb85f91bb5308648eb8301d5a08be239561722149ecf759b35561edd99/python/mypy/issues/7981 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6b067edb85f91bb5308648eb8301d5a08be239561722149ecf759b35561edd99/python/mypy/issues/7981 |
| og:image:alt | Reopened from #7845 as requested mypy seems to ignore the @final decorator when it is applied to a TypedDict. This issue becomes material when one invokes the items() or values() methods, or passes... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | crusaderky |
| 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