Title: Positional arguments to TypedDict constructor · Issue #2161 · python/typing · GitHub
Open Graph Title: Positional arguments to TypedDict constructor · Issue #2161 · python/typing
X Title: Positional arguments to TypedDict constructor · Issue #2161 · python/typing
Description: The spec says "The constructor takes only keyword arguments, corresponding to the items of the TypedDict." This derives from wording in PEP 589 "It can be used as a callable object with keyword arguments corresponding to the TypedDict it...
Open Graph Description: The spec says "The constructor takes only keyword arguments, corresponding to the items of the TypedDict." This derives from wording in PEP 589 "It can be used as a callable object with keyword arg...
X Description: The spec says "The constructor takes only keyword arguments, corresponding to the items of the TypedDict." This derives from wording in PEP 589 "It can be used as a callable object w...
Opengraph URL: https://github.com/python/typing/issues/2161
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Positional arguments to TypedDict constructor","articleBody":"The [spec](https://typing.python.org/en/latest/spec/typeddict.html#the-typeddict-constructor) says \"The constructor takes only keyword arguments, corresponding to the items of the TypedDict.\" This derives from wording in [PEP 589](https://peps.python.org/pep-0589/#using-typeddict-types) \"It can be used as a callable object with keyword arguments corresponding to the TypedDict items. Non-keyword arguments are not allowed.\"\n\nBut at runtime, the TypedDict constructor also takes positional arguments. This works:\n\n```python\nfrom typing import TypedDict\nclass TD1(TypedDict):\n a: int\nclass TD2(TD1):\n b: str\n\ndef f(x: TD2) -> TD1:\n return TD1(x)\n```\n\nPyright allows this program; mypy does not and reports `Expected keyword arguments, {...}, or dict(...) in TypedDict constructor`.\n\nThe spec should say whether or not this should be allowed. (My opinion: it should be allowed, since it works at runtime and doesn't appear to break any type safety rule.)\n\nAt runtime, even more is allowed; the TypedDict constructor actually allows whatever `dict()` allows. So you could do `TD1([(\"a\", 1)])`, or `TD1(TD2, a=3)`. Pyright allows some but not all of that. I'm inclined to prohibit anything other than calls with keyword arguments and calls with a single positional argument of TypedDict type; anything else is rarely useful and prone to unsound behavior.","author":{"url":"https://github.com/JelleZijlstra","@type":"Person","name":"JelleZijlstra"},"datePublished":"2026-01-28T03:50:25Z","url":"https://github.com/python/typing/issues/2161"}
| 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:d18f2598-5f13-a7eb-efd2-c41caa585fab |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B5FC:284244:1AE8F7:22FA10:6AFF8459 |
| html-safe-nonce | ac31d1f398605594234b96da512bb8a8e76538309d8b2716a759c88956ffdbd9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNUZDOjI4NDI0NDoxQUU4Rjc6MjJGQTEwOjZBRkY4NDU5IiwidmlzaXRvcl9pZCI6IjY4MjgyOTE2OTkzNTgyNzA1NTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9536fdbafb2e9ad57d07a0c65d0b73655ac53c0fff6c6f780bd1a38fd89567bd |
| hovercard-subject-tag | issue:3863416888 |
| 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/typing/2161/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d2c3f35e77cfe93e1a86151cd24d4a3710ab8bba8188040f18b9c541d1366238/python/typing/issues/2161 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d2c3f35e77cfe93e1a86151cd24d4a3710ab8bba8188040f18b9c541d1366238/python/typing/issues/2161 |
| og:image:alt | The spec says "The constructor takes only keyword arguments, corresponding to the items of the TypedDict." This derives from wording in PEP 589 "It can be used as a callable object with keyword arg... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JelleZijlstra |
| hostname | github.com |
| expected-hostname | github.com |
| None | 19488db4031f00b04ea79b4c70b5dd32cfa873a8d20b3877f3896b8e2d195946 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typing git https://github.com/python/typing.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 24604008 |
| octolytics-dimension-repository_nwo | python/typing |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24604008 |
| octolytics-dimension-repository_network_root_nwo | python/typing |
| 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 | 7952f5285f4ba685d70c4c7540ad3cc9dc9746b8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width