Title: Deprecate unusual ways of creating empty TypedDicts · Issue #105570 · python/cpython · GitHub
Open Graph Title: Deprecate unusual ways of creating empty TypedDicts · Issue #105570 · python/cpython
X Title: Deprecate unusual ways of creating empty TypedDicts · Issue #105570 · python/cpython
Description: Feature or enhancement I propose that we deprecate the following two ways of creating empty TypedDicts: from typing import TypedDict T = TypedDict("T") T2 = TypedDict("T2", None) Pitch Users currently have four distinct options if they w...
Open Graph Description: Feature or enhancement I propose that we deprecate the following two ways of creating empty TypedDicts: from typing import TypedDict T = TypedDict("T") T2 = TypedDict("T2", None) Pitch Users curren...
X Description: Feature or enhancement I propose that we deprecate the following two ways of creating empty TypedDicts: from typing import TypedDict T = TypedDict("T") T2 = TypedDict("T2", None...
Opengraph URL: https://github.com/python/cpython/issues/105570
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Deprecate unusual ways of creating empty TypedDicts","articleBody":"# Feature or enhancement\r\n\r\nI propose that we deprecate the following two ways of creating empty `TypedDict`s:\r\n\r\n```py\r\nfrom typing import TypedDict\r\n\r\nT = TypedDict(\"T\")\r\nT2 = TypedDict(\"T2\", None)\r\n```\r\n\r\n# Pitch\r\n\r\nUsers currently have four distinct options if they want to create an empty `TypedDict` with no fields:\r\n\r\n```py\r\nT = TypedDict(\"T\")\r\nT2 = TypedDict(\"T2\", None)\r\nT3 = TypedDict(\"T3\", {})\r\nclass T4(TypedDict): ...\r\n```\r\n\r\nOf these four options, only `T3` and `T4` are supported by type checkers. `typing.TypedDict` has been around for a while now, so if `T1` and `T2` are still unsupported by type checkers, they probably never will be supported.\r\n\r\nDeprecating, and eventually removing, the first two ways of constructing empty TypedDicts will allow us to simplify the code at runtime. It will also be less confusing for users. Every way in which the runtime and type checkers differ in behaviour is a potential point of confusion for users; in general, we should work to keep these points of difference to a minimum.\r\n\r\nI also don't think these methods of constructing empty TypedDicts are particularly common.\r\n\r\n# Previous discussion\r\n\r\nFor very similar reasons, we previously deprecated and removed the keyword-argument syntax for creating TypedDicts. This was deprecated in 3.11, and removed in 3.13:\r\n\r\n- https://github.com/python/cpython/issues/90224\r\n- https://github.com/python/cpython/issues/104786\r\n\r\nIn retrospect, we should really have deprecated these ways of creating empty TypedDicts at the same time. But there's no way of changing that now.\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-105780\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/AlexWaygood","@type":"Person","name":"AlexWaygood"},"datePublished":"2023-06-09T15:43:54Z","url":"https://github.com/python/cpython/issues/105570"}
| 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:77676253-aeb5-610e-5884-c2cebbfb1292 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AFE2:07D0:1620BDD:1D32A29:6B0020CA |
| html-safe-nonce | b4cbe06c4a59be0ecbbc0ccda0467d85a01a96e82e255e179c7667ad82555cc5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRkUyOjA3RDA6MTYyMEJERDoxRDMyQTI5OjZCMDAyMENBIiwidmlzaXRvcl9pZCI6Ijc0NjA4MzM5MjI3MDQ3NDQ2NTAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 47b41fe068f1d27a626d282748f440597bbf9bbaae5fe6acc6858151e08f8a50 |
| hovercard-subject-tag | issue:1750125673 |
| 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/cpython/105570/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d23ac4192a8c9eb4f4c55f19a9a7950cb697a7ff3a15e196200edc4acc72b743/python/cpython/issues/105570 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d23ac4192a8c9eb4f4c55f19a9a7950cb697a7ff3a15e196200edc4acc72b743/python/cpython/issues/105570 |
| og:image:alt | Feature or enhancement I propose that we deprecate the following two ways of creating empty TypedDicts: from typing import TypedDict T = TypedDict("T") T2 = TypedDict("T2", None) Pitch Users curren... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AlexWaygood |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| 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