René's URL Explorer Experiment


Title: Literal types tracking issue · Issue #5935 · python/mypy · GitHub

Open Graph Title: Literal types tracking issue · Issue #5935 · python/mypy

X Title: Literal types tracking issue · Issue #5935 · python/mypy

Description: This issue tracks TODOs for literal types. Core work Modify the parser so it can handle literal expressions in types (#5947) Make any necessary changes to semantic analysis (see below) (#5947) Implement the core type-checking logic (also...

Open Graph Description: This issue tracks TODOs for literal types. Core work Modify the parser so it can handle literal expressions in types (#5947) Make any necessary changes to semantic analysis (see below) (#5947) Impl...

X Description: This issue tracks TODOs for literal types. Core work Modify the parser so it can handle literal expressions in types (#5947) Make any necessary changes to semantic analysis (see below) (#5947) Impl...

Opengraph URL: https://github.com/python/mypy/issues/5935

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Literal types tracking issue","articleBody":"This issue tracks TODOs for literal types.\r\n\r\n## Core work\r\n\r\n- [x] Modify the parser so it can handle literal expressions in types (https://github.com/python/mypy/pull/5947)\r\n- [x] Make any necessary changes to semantic analysis (see below) (https://github.com/python/mypy/pull/5947)\r\n- [x] Implement the core type-checking logic (also see below)\r\n- [x] Implement logic for determining when and when not to infer Literal (https://github.com/python/mypy/pull/5990)\r\n- [x] Validate that everything works in incremental mode and with the mypy daemon (https://github.com/python/mypy/pull/6075)\r\n- [ ] Add \"extra\" features (again see below)\r\n- [x] Write docs\r\n\r\n## Parsing/semantic analysis follow-up tasks\r\n\r\n- [x] Distinguish between byte strings, native strings, and unicode in Python 2 and Python 3 (https://github.com/python/mypy/pull/6087)\r\n- [x] Make sure everything still works with `from __future__ import unicode_literals` (https://github.com/python/mypy/pull/6087)\r\n- [x] Add more tests for forward references and related shenanigans\r\n- [x] Add logic to make sure literal expressions are coerced to the correct type based on context (https://github.com/python/mypy/pull/5990)\r\n\r\n## Error messages\r\n\r\n- [x] Add better error messages for complex numbers (https://github.com/python/mypy/pull/6149)\r\n- [x] Add better error messages for weird expressions in general (e.g. disallowing `Literal[1 + 2]`. This will probably involve moving *all* invalid type checking into the semantic analysis layer? (https://github.com/python/mypy/pull/6149)\r\n- [x] Resolve https://github.com/python/mypy/issues/5989 (https://github.com/python/mypy/pull/6149)\r\n\r\n## Implementing and testing type visitors\r\n\r\nImplement and write tests that exercise the following visitors. (Introduced by https://github.com/python/mypy/pull/5934)\r\n\r\n- [x] constraints.ConstraintBuilderVisitor (https://github.com/python/mypy/pull/5990)\r\n- [x] join.TypeJoinVisitor (https://github.com/python/mypy/pull/5990)\r\n- [x] meet.TypeMeetVisitor (https://github.com/python/mypy/pull/6043)\r\n- [x] subtypes.ProperSubtypeVisitor (https://github.com/python/mypy/pull/5947)\r\n- [x] subtypes.SubtypeVisitor (https://github.com/python/mypy/pull/5947)\r\n- [x] typeanal.TypeAnalyzer (https://github.com/python/mypy/pull/5947)\r\n- [x] typeanal.TypeAnalyzerPass3 (https://github.com/python/mypy/pull/5947)\r\n- [x] types.TypeStrVisitor (https://github.com/python/mypy/pull/5947)\r\n- [x] type_visitor.TypeVisitor (indirectly, by other tests)\r\n- [x] type_visitor.TypeTranslator (indirectly, by other tests)\r\n\r\nThe following have preliminary implementations, but are missing associated tests:\r\n\r\n- [x] erasetype.EraseTypeVisitor (indirectly, by https://github.com/python/mypy/pull/6035)\r\n- [x] expandtype.ExpandTypeVisitor (indirectly, by https://github.com/python/mypy/pull/6035)\r\n- [ ] fixup.TypeFixer (important for Enums)\r\n- [x] sametypes.SameTypeVisitor (https://github.com/python/mypy/pull/6043)\r\n- [x] server.astdiff.SnapshotTypeVisitor (https://github.com/python/mypy/pull/6075)\r\n- [x] server.deps.TypeTriggersVisitor (https://github.com/python/mypy/pull/6075)\r\n\r\n## Other checks to add in the type-checking layer\r\n\r\n- [x] Make sure we cannot subclass Literals (https://github.com/python/mypy/pull/6034)\r\n- [ ] Blacklist constructs like `Type[Literal[4]]`\r\n    - Actually, should we? Maybe we should treat `Type[Literal[4]]` as `int` instead -- this might make certain TypeVar shenanigans more smooth. Need to discuss.\r\n    - Actually, the above idea seems like a bad idea: if we do `x: Literal[3]`, doing `type(x)` ought to return a value with type `Type[int]`, not just `int`.\r\n- [x] Blacklist using `Literal[...]` in `isinstance` and `issubclass` checks (https://github.com/python/mypy/pull/6034)\r\n- [x] Validate `Literal` works as expected when used in generics (https://github.com/python/mypy/pull/6035)\r\n- [ ] Consider having mypy warn if somebody tries doing literally `TypeVar('T', bound=Literal[4])`? Need to discuss first.\r\n\r\n\r\n## \"Extra\" features to add\r\n\r\n- [x] Intelligent indexing of tuples, NamedTuples, TypedDict, getattr, and setattr (https://github.com/python/mypy/pull/6124)\r\n    - While I'm at it, design a more intelligent \"macro replace\" system and try and fix the misc errors we get when using `--disallow-any-expr`?\r\n- [x] Type narrowing with equality and inequality checks\r\n- [x] Interactions with `Final` (https://github.com/python/mypy/pull/6081)\r\n- [x] Add custom type guards (see Ivan's comment below, also https://github.com/python/mypy/issues/5206)\r\n- [x] Treat bool as a union of `Literal[True]` and `Literal[False]` (see https://github.com/python/mypy/issues/6113)\r\n\r\n## Things to do before mypy 0.660 is released if literal types aren't going to make it\r\n\r\n- [x] Address https://github.com/python/mypy/issues/5989 -- restore old error messages, and expunge any reference to literal types in any error messages we added. (https://github.com/python/mypy/pull/6121)\r\n\r\n## Other things\r\n\r\n- [x] Try replacing one of the functions we currently manage using plugins with literal types instead, and see what happens.\r\n    - I tried replacing the \"open(...)\" plugin and re-ran mypy on one of our smaller internal codebases. Out of approximately 680 calls to `open`, about 610 of them had 2 or more arguments. We inferred the correct type for about 560 of those. About another 20 of these were passing in string variable arguments as the mode. The remaining 30 require a little more investigation -- some people were passing in `**kwargs` or `**args` in as the argument, etc...\r\n\r\n## Things that have been deferred to after this project is completed\r\n\r\n- Adding support for enums in literal types (and while I'm at it, I might as well investigate overhauling enums in general). Related tasks:\r\n    - Treat enum classes as roughly a union of their values\r\n    - Better error messages for bad imports (e.g. enums with a coerced type of 'Any')\r\n- In error messages, we seem to quote types using either single quotes or double quotes. This can sometimes lead to messy-looking error messages (e.g. `Revealed type is 'Literal['foo']'`). We should standardize on a specific quoting scheme + avoid this weird \"nesting\" issue.\r\n- Make sure we report an error when somebody tries doing `Literal[3]()` (and `Final[int]()` and `Protocol[blah]()`...)\r\n","author":{"url":"https://github.com/Michael0x2a","@type":"Person","name":"Michael0x2a"},"datePublished":"2018-11-21T19:20:19Z","url":"https://github.com/python/mypy/issues/5935"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:28132358-74ec-f14b-780a-b54d687db5c1
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDE10:1F52F6:4EA504:69C54D:6B002FE3
html-safe-nonce23494bdfa3863fe1cb61e902d838f4745cdb28f22940ea53fb9f59cf8812d02b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERTEwOjFGNTJGNjo0RUE1MDQ6NjlDNTREOjZCMDAyRkUzIiwidmlzaXRvcl9pZCI6IjU2NTEwOTEwNzEwNDQ2OTM5ODciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacf3a0c653ed8a9355de8b646be126369574f3fa4efc8ff432b9feee8ab5f07b62
hovercard-subject-tagissue:383261076
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/mypy/5935/issue_layout
twitter:imagehttps://opengraph.githubassets.com/3eabcf6f54a10e2f900240543ff3c99a263e3d1672502238375fc7c16d52e332/python/mypy/issues/5935
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/3eabcf6f54a10e2f900240543ff3c99a263e3d1672502238375fc7c16d52e332/python/mypy/issues/5935
og:image:altThis issue tracks TODOs for literal types. Core work Modify the parser so it can handle literal expressions in types (#5947) Make any necessary changes to semantic analysis (see below) (#5947) Impl...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameMichael0x2a
hostnamegithub.com
expected-hostnamegithub.com
None7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0
turbo-cache-controlno-preview
go-importgithub.com/python/mypy git https://github.com/python/mypy.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id7053637
octolytics-dimension-repository_nwopython/mypy
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id7053637
octolytics-dimension-repository_network_root_nwopython/mypy
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasef3f3a43ca095cdea3abbb394112e971f9fdb94fa
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/mypy/issues/5935#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F5935
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fissues%2F5935
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fmypy
Reloadhttps://github.com/python/mypy/issues/5935
Reloadhttps://github.com/python/mypy/issues/5935
Reloadhttps://github.com/python/mypy/issues/5935
pythonhttps://github.com/python
mypyhttps://github.com/python/mypy
Codehttps://github.com/python/mypy
Issues2.7k (2.7k)https://github.com/python/mypy/issues
Pull requests547 (547)https://github.com/python/mypy/pulls
Actionshttps://github.com/python/mypy/actions
Projectshttps://github.com/python/mypy/projects
Wikihttps://github.com/python/mypy/wiki
Security and qualityhttps://github.com/python/mypy/security
Insightshttps://github.com/python/mypy/insights
https://github.com/python/mypy
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/5935
New issuehttps://github.com/login?return_to=https://github.com/python/mypy/issues/5935
Literal types tracking issuehttps://github.com/python/mypy/issues/5935#top
https://github.com/Michael0x2a
metaIssues tracking a broad area of workhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22meta%22
topic-literal-typeshttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-literal-types%22
https://github.com/Michael0x2a
Michael0x2ahttps://github.com/Michael0x2a
on Nov 21, 2018https://github.com/python/mypy/issues/5935#issue-383261076
Add basic end-to-end support for Literal types #5947https://github.com/python/mypy/pull/5947
Add basic end-to-end support for Literal types #5947https://github.com/python/mypy/pull/5947
Make literal exprs have inferred type of 'Literal' based on context #5990https://github.com/python/mypy/pull/5990
Add tests for Literal types with incremental and fine-grained mode #6075https://github.com/python/mypy/pull/6075
Add support for byte and unicode Literal strings #6087https://github.com/python/mypy/pull/6087
Add support for byte and unicode Literal strings #6087https://github.com/python/mypy/pull/6087
Make literal exprs have inferred type of 'Literal' based on context #5990https://github.com/python/mypy/pull/5990
Improve error messages related to literal types #6149https://github.com/python/mypy/pull/6149
Improve error messages related to literal types #6149https://github.com/python/mypy/pull/6149
Regression: error messages for literal expressions in invalid places are worse #5989https://github.com/python/mypy/issues/5989
Improve error messages related to literal types #6149https://github.com/python/mypy/pull/6149
#5934https://github.com/python/mypy/pull/5934
Make literal exprs have inferred type of 'Literal' based on context #5990https://github.com/python/mypy/pull/5990
Make literal exprs have inferred type of 'Literal' based on context #5990https://github.com/python/mypy/pull/5990
Implement meet for literal types; add tests for 'is_same_type' #6043https://github.com/python/mypy/pull/6043
Add basic end-to-end support for Literal types #5947https://github.com/python/mypy/pull/5947
Add basic end-to-end support for Literal types #5947https://github.com/python/mypy/pull/5947
Add basic end-to-end support for Literal types #5947https://github.com/python/mypy/pull/5947
Add basic end-to-end support for Literal types #5947https://github.com/python/mypy/pull/5947
Add basic end-to-end support for Literal types #5947https://github.com/python/mypy/pull/5947
Add tests for literals and generics #6035https://github.com/python/mypy/pull/6035
Add tests for literals and generics #6035https://github.com/python/mypy/pull/6035
Implement meet for literal types; add tests for 'is_same_type' #6043https://github.com/python/mypy/pull/6043
Add tests for Literal types with incremental and fine-grained mode #6075https://github.com/python/mypy/pull/6075
Add tests for Literal types with incremental and fine-grained mode #6075https://github.com/python/mypy/pull/6075
Prohibit some illegal uses of Literal #6034https://github.com/python/mypy/pull/6034
Prohibit some illegal uses of Literal #6034https://github.com/python/mypy/pull/6034
Add tests for literals and generics #6035https://github.com/python/mypy/pull/6035
Add intelligent indexing of tuples, NamedTuples, and TypedDict #6124https://github.com/python/mypy/pull/6124
Add interactions between Literal and Final #6081https://github.com/python/mypy/pull/6081
type refinement in function call #5206https://github.com/python/mypy/issues/5206
Treat bool as equivalent to Literal[True, False] to allow better type inference #6113https://github.com/python/mypy/issues/6113
Regression: error messages for literal expressions in invalid places are worse #5989https://github.com/python/mypy/issues/5989
Remove RawLiteralType synthetic type #6121https://github.com/python/mypy/pull/6121
Michael0x2ahttps://github.com/Michael0x2a
topic-literal-typeshttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-literal-types%22
on Nov 21, 2018https://github.com/python/mypy/issues/5935#event-1980915306
https://github.com/JukkaL
JukkaLhttps://github.com/JukkaL
on Nov 22, 2018https://github.com/python/mypy/issues/5935#issuecomment-441101428
Michael0x2ahttps://github.com/Michael0x2a
on Nov 22, 2018https://github.com/python/mypy/issues/5935#event-1983069402
Add LiteralType and stub methods to type visitors (#5934)https://github.com/python/mypy/commit/b099496568ebb53e0a1345f470846f054562687e
#5934https://github.com/python/mypy/pull/5934
b099496https://github.com/python/mypy/commit/b099496568ebb53e0a1345f470846f054562687e
Michael0x2ahttps://github.com/Michael0x2a
on Nov 24, 2018https://github.com/python/mypy/issues/5935#event-1984885313
https://github.com/ilevkivskyi
ilevkivskyihttps://github.com/ilevkivskyi
on Dec 22, 2018https://github.com/python/mypy/issues/5935#issuecomment-449597779
https://github.com/ilevkivskyi
ilevkivskyihttps://github.com/ilevkivskyi
on Jun 14, 2019https://github.com/python/mypy/issues/5935#issuecomment-502070423
@Michael0x2ahttps://github.com/Michael0x2a
#5206https://github.com/python/mypy/issues/5206
97littleleaf11https://github.com/97littleleaf11
metaIssues tracking a broad area of workhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22meta%22
on Nov 12, 2021https://github.com/python/mypy/issues/5935#event-5608450671
https://github.com/emmatyping
emmatypinghttps://github.com/emmatyping
on May 19, 2022https://github.com/python/mypy/issues/5935#issuecomment-1131542603
https://github.com/hauntsaninja
hauntsaninjahttps://github.com/hauntsaninja
on Nov 12, 2023https://github.com/python/mypy/issues/5935#issuecomment-1807268223
hauntsaninjahttps://github.com/hauntsaninja
completedhttps://github.com/python/mypy/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Nov 12, 2023https://github.com/python/mypy/issues/5935#event-10935552262
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/mypy/issues/5935
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/mypy/issues/5935
Michael0x2ahttps://github.com/Michael0x2a
metaIssues tracking a broad area of workhttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22meta%22
topic-literal-typeshttps://github.com/python/mypy/issues?q=state%3Aopen%20label%3A%22topic-literal-types%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.