Title: Using `Literal` typed variables as keys for TypedDict causes "TypedDict key must be a string literal" · Issue #6262 · python/mypy · GitHub
Open Graph Title: Using `Literal` typed variables as keys for TypedDict causes "TypedDict key must be a string literal" · Issue #6262 · python/mypy
X Title: Using `Literal` typed variables as keys for TypedDict causes "TypedDict key must be a string literal" · Issue #6262 · python/mypy
Description: Please provide more information to help us understand the issue: Are you reporting a bug, or opening a feature request? Bug Please insert below the code you are checking with mypy, or a mock-up repro if the source is private. We would ap...
Open Graph Description: Please provide more information to help us understand the issue: Are you reporting a bug, or opening a feature request? Bug Please insert below the code you are checking with mypy, or a mock-up rep...
X Description: Please provide more information to help us understand the issue: Are you reporting a bug, or opening a feature request? Bug Please insert below the code you are checking with mypy, or a mock-up rep...
Opengraph URL: https://github.com/python/mypy/issues/6262
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Using `Literal` typed variables as keys for TypedDict causes \"TypedDict key must be a string literal\"","articleBody":"Please provide more information to help us understand the issue:\r\n\r\n* Are you reporting a bug, or opening a feature request?\r\nBug\r\n\r\n* Please insert below the code you are checking with mypy,\r\n or a mock-up repro if the source is private. We would appreciate\r\n if you try to simplify your case to a minimal repro.\r\n\r\n```\r\nfrom mypy_extensions import TypedDict\r\nfrom typing_extensions import Literal\r\n\r\nclass Test(TypedDict):\r\n a: str\r\n b: str\r\n\r\nTestKey = Literal['a', 'b']\r\n\r\ndef read(test: Test, key: TestKey):\r\n return test[key]\r\n```\r\n\r\n* What is the actual behavior/output?\r\nmypy.py:13: error: TypedDict key must be a string literal; expected one of ('a', 'b')\r\n\r\n* What is the behavior/output you expect?\r\nNo type check errors\r\n\r\n* What are the versions of mypy and Python you are using?\r\nmypy -- 0.660\r\npython -- 3.6.3\r\n\r\n Do you see the same issue after installing mypy from Git master?\r\nYes\r\n\r\n* What are the mypy flags you are using? (For example --strict-optional)\r\nNone\r\n\r\n* If mypy crashed with a traceback, please paste\r\n the full traceback below.\r\n\r\n(You can freely edit this text, please remove all the lines\r\nyou believe are unnecessary.)\r\n","author":{"url":"https://github.com/chungwu","@type":"Person","name":"chungwu"},"datePublished":"2019-01-28T21:03:45Z","url":"https://github.com/python/mypy/issues/6262"}
| 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:6db2f664-deb4-9a86-933c-90bc63c18de4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DB34:2A087:4D47E1:676494:6B002FC6 |
| html-safe-nonce | 89ec4131a3bdc124e95ee990ddf88a41b39832fee1df34f4dbbd095ba7137ed1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjM0OjJBMDg3OjRENDdFMTo2NzY0OTQ6NkIwMDJGQzYiLCJ2aXNpdG9yX2lkIjoiMjQ4MDExMDI2NTM2NzAxNTM2NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b5cd4dac647571a70b96f18df295ae611f9f8cecb03fdd344718d807c954cc8a |
| hovercard-subject-tag | issue:404006072 |
| 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/6262/issue_layout |
| twitter:image | https://opengraph.githubassets.com/330c092370f27adf4cc2d20b91776f7f382e5610cf7924938089921cffeb74a8/python/mypy/issues/6262 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/330c092370f27adf4cc2d20b91776f7f382e5610cf7924938089921cffeb74a8/python/mypy/issues/6262 |
| og:image:alt | Please provide more information to help us understand the issue: Are you reporting a bug, or opening a feature request? Bug Please insert below the code you are checking with mypy, or a mock-up rep... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | chungwu |
| 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