Title: final TypedDict with total=False does not allow clear/popitem · Issue #14914 · python/mypy · GitHub
Open Graph Title: final TypedDict with total=False does not allow clear/popitem · Issue #14914 · python/mypy
X Title: final TypedDict with total=False does not allow clear/popitem · Issue #14914 · python/mypy
Description: Bug Report PEP-589 disallows clear and popitem on TypedDicts, even if all known keys are not required, as there may be other required keys due to structural subtyping. However, a @final-decorated TypedDict cannot be structurally subtyped...
Open Graph Description: Bug Report PEP-589 disallows clear and popitem on TypedDicts, even if all known keys are not required, as there may be other required keys due to structural subtyping. However, a @final-decorated T...
X Description: Bug Report PEP-589 disallows clear and popitem on TypedDicts, even if all known keys are not required, as there may be other required keys due to structural subtyping. However, a @final-decorated T...
Opengraph URL: https://github.com/python/mypy/issues/14914
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"final TypedDict with total=False does not allow clear/popitem","articleBody":"**Bug Report**\r\n\r\nPEP-589 disallows clear and popitem on TypedDicts, even if all known keys are not required, as there may be other required keys due to structural subtyping. However, a `@final`-decorated TypedDict cannot be structurally subtyped, so these methods should be available.\r\n\r\n**To Reproduce**\r\n\r\nhttps://mypy-play.net/?mypy=latest&python=3.11&gist=7d42af8206cb1e25a53673bdf4e99df1\r\n```python\r\nfrom typing import TypedDict, final\r\n\r\n@final\r\nclass A(TypedDict, total=False):\r\n k: int\r\n\r\na: A = {\"k\": 1}\r\na.clear()\r\n```\r\n\r\n**Expected Behavior**\r\n\r\nNo errors\r\n\r\n**Actual Behavior**\r\n\r\n```text\r\nerror: \"A\" has no attribute \"clear\" [attr-defined]\r\n```\r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: 1.0.0\r\n- Python version used: 3.11","author":{"url":"https://github.com/alicederyn","@type":"Person","name":"alicederyn"},"datePublished":"2023-03-17T09:31:14Z","url":"https://github.com/python/mypy/issues/14914"}
| 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:52f792da-e109-b315-db17-74089fa61013 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C57C:F5AA9:21F0750:2E29AD0:6B0025AD |
| html-safe-nonce | 7cc8137dad52a5df4aa18727602c9b3ee998cd90e74a3d55b92b711bf0fde50d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNTdDOkY1QUE5OjIxRjA3NTA6MkUyOUFEMDo2QjAwMjVBRCIsInZpc2l0b3JfaWQiOiI4ODE3MDcyOTI0NjA4NTI2NTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e75af0adb6f980d69feb063d861593a07534bb46eda7eec025e16459688bed7e |
| hovercard-subject-tag | issue:1628987113 |
| 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/14914/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7d92a1898efa5ced48d5c85e7b805b6f96775f0da58be6e1666d4d7aceee4c5e/python/mypy/issues/14914 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7d92a1898efa5ced48d5c85e7b805b6f96775f0da58be6e1666d4d7aceee4c5e/python/mypy/issues/14914 |
| og:image:alt | Bug Report PEP-589 disallows clear and popitem on TypedDicts, even if all known keys are not required, as there may be other required keys due to structural subtyping. However, a @final-decorated T... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | alicederyn |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width