Title: Discrepancy between spec and tests on indexing TypedDicts with unknown literal keys · Issue #2054 · python/typing · GitHub
Open Graph Title: Discrepancy between spec and tests on indexing TypedDicts with unknown literal keys · Issue #2054 · python/typing
X Title: Discrepancy between spec and tests on indexing TypedDicts with unknown literal keys · Issue #2054 · python/typing
Description: Splitting issue from PR #1978 Spec says that indexing with unknown literal keys should be reported as an error: The use of a key that is not known to exist should be reported as an error, even if this wouldn’t necessarily generate a runt...
Open Graph Description: Splitting issue from PR #1978 Spec says that indexing with unknown literal keys should be reported as an error: The use of a key that is not known to exist should be reported as an error, even if t...
X Description: Splitting issue from PR #1978 Spec says that indexing with unknown literal keys should be reported as an error: The use of a key that is not known to exist should be reported as an error, even if t...
Opengraph URL: https://github.com/python/typing/issues/2054
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Discrepancy between spec and tests on indexing TypedDicts with unknown literal keys","articleBody":"*Splitting issue from PR https://github.com/python/typing/pull/1978*\n\nSpec says that indexing with unknown literal keys should be reported as an error:\n\n> **The use of a key that is not known to exist should be reported as an error, even if this wouldn’t necessarily generate a runtime type error.** These are often mistakes, and these may insert values with an invalid type if structural assignability hides the types of certain items. For example, d[‘x’] = 1 should generate a type check error if ‘x’ is not a valid key for d (which is assumed to be a TypedDict type).\n\nBut it's not reflected in conformance tests (https://github.com/python/typing/blob/2d88da2a407b556f5b52b4c6ad1bd659873bb9ac/conformance/tests/typeddicts_operations.py) and there's a bit of discrepancy between type checkers how they handle some cases (most of them reject all cases that may cause runtime error / allow cases that do not cause runtime error ).\n\nWould be great if we can either adapt conformance tests to the spec or amend the spec to remove the ambiguity.\n\nRelated discussion - https://discuss.python.org/t/typeddict-operations-with-unknown-literal-keys/89653 (also has information on state of this issue in different type checkers).","author":{"url":"https://github.com/Andrej730","@type":"Person","name":"Andrej730"},"datePublished":"2025-07-21T19:11:49Z","url":"https://github.com/python/typing/issues/2054"}
| 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:d5f36be6-092f-22aa-24d9-89eca2fbf6c5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C1D2:1833B7:5DFE57:7F1224:6AFF88B9 |
| html-safe-nonce | 4e90cf8fc4e2dfc5578de4c0b8f5453efe4676df53b5eb1f80991d6275c3a138 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMUQyOjE4MzNCNzo1REZFNTc6N0YxMjI0OjZBRkY4OEI5IiwidmlzaXRvcl9pZCI6IjEyODk3NjU0MTM2Mjk5NTQyMzMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 00e764fcee438670211578ad4f1862c2b4f54f5b820fa834283ae94da6ad3a55 |
| hovercard-subject-tag | issue:3249737547 |
| 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/2054/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4038e55fa408edca291adc114a299b02568be160835dc144c45a4bfa1b9f01a6/python/typing/issues/2054 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4038e55fa408edca291adc114a299b02568be160835dc144c45a4bfa1b9f01a6/python/typing/issues/2054 |
| og:image:alt | Splitting issue from PR #1978 Spec says that indexing with unknown literal keys should be reported as an error: The use of a key that is not known to exist should be reported as an error, even if t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Andrej730 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 587ad99a3e443b2e1cb0d3df059ec49ab54389861f13310766dfdeb615fed90d |
| 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 | 5bb0fb68d64881d1344f5863d809515d496801e5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width