Title: Finals and Literals: Spec contradiction · Issue #2351 · python/typing · GitHub
Open Graph Title: Finals and Literals: Spec contradiction · Issue #2351 · python/typing
X Title: Finals and Literals: Spec contradiction · Issue #2351 · python/typing
Description: This came up in python/typeshed#16301. I assume this is mostly a clerical/historical error, but let me know if we should follow the whole spec change process. The typing spec says about Final: Example: ID: Final = 1 The typechecker shoul...
Open Graph Description: This came up in python/typeshed#16301. I assume this is mostly a clerical/historical error, but let me know if we should follow the whole spec change process. The typing spec says about Final: Exam...
X Description: This came up in python/typeshed#16301. I assume this is mostly a clerical/historical error, but let me know if we should follow the whole spec change process. The typing spec says about Final: Exam...
Opengraph URL: https://github.com/python/typing/issues/2351
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Finals and Literals: Spec contradiction","articleBody":"This came up in python/typeshed#16301. I assume this is mostly a clerical/historical error, but let me know if we should follow the whole spec change process.\n\n----\n\nThe typing spec [says about `Final`](https://typing.python.org/en/latest/spec/qualifiers.html#syntax):\n\n> Example:\n> \n> `ID: Final = 1`\n>\n> The typechecker should apply its usual type inference mechanisms to determine the type of ID (here, likely, int).\n\nAnd then a bit later:\n\n> Type checkers should treat uses of a final name that was initialized with a literal as if it was replaced by the literal.\n\nBoth sentences are copied directly from [PEP 591](https://peps.python.org/pep-0591/), which overlapped with the Literals [PEP 586](https://peps.python.org/pep-0586/).\n\nI assume that we should change the first sentence to \"here, likely, `Literal[1]`\" and change the second sentence to be a bit more concrete along these lines: \n\n> Type checkers should infer uses of a final name that was initialized with a literal `X` as `Literal[X]` if `X` is an allowed literal type (cf. to the literals section). Otherwise, they should infer the type of the `X`.\n\n(And maybe extend the example after a bit.)\n\nIn fact, this is what the conformance tests already check:\n\nhttps://github.com/python/typing/blob/cf943ccbea5596ef969eec6e2260097ff697b7ba/conformance/tests/qualifiers_final_annotation.py#L11-L13\n\n(Although the tests could be extended a bit.)","author":{"url":"https://github.com/srittau","@type":"Person","name":"srittau"},"datePublished":"2026-08-31T14:51:26Z","url":"https://github.com/python/typing/issues/2351"}
| 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:67ba8607-f51b-6b7f-d51e-ff9cde0ea510 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8C3A:D064:5C16DE:7C798B:6AFF878B |
| html-safe-nonce | 8806789b1154ee4e83b8352250c124735b815da2d29b8955877f15fa69cb796f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzNBOkQwNjQ6NUMxNkRFOjdDNzk4Qjo2QUZGODc4QiIsInZpc2l0b3JfaWQiOiIyMDUwOTIxNjU2NzIwNzg3MzM5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 21a80c87782cedcdc9781ccb910210b1c91872f2a25896e12ccc577c627fee3d |
| hovercard-subject-tag | issue:5301549182 |
| 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/2351/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3444521c67d6f5b176a5dd9963acfd684f8cd2776431dbb53f558b0bb5b178b2/python/typing/issues/2351 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3444521c67d6f5b176a5dd9963acfd684f8cd2776431dbb53f558b0bb5b178b2/python/typing/issues/2351 |
| og:image:alt | This came up in python/typeshed#16301. I assume this is mostly a clerical/historical error, but let me know if we should follow the whole spec change process. The typing spec says about Final: Exam... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | srittau |
| 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