René's URL Explorer Experiment


Title: Improved `Literal?` types by randolf-scholz · Pull Request #20444 · python/mypy · GitHub

Open Graph Title: Improved `Literal?` types by randolf-scholz · Pull Request #20444 · python/mypy

X Title: Improved `Literal?` types by randolf-scholz · Pull Request #20444 · python/mypy

Description: Optional static typing for Python. Contribute to python/mypy development by creating an account on GitHub.

Open Graph Description: This PR aims to formalize the behavior of Literal? types (Instance with last_known_value) by treating them as-if they were AnyOf-types (see python/typing#566) For example, Literal["x"]? i...

X Description: This PR aims to formalize the behavior of Literal? types (Instance with last_known_value) by treating them as-if they were AnyOf-types (see python/typing#566) For example, Literal["x&q...

Opengraph URL: https://github.com/python/mypy/pull/20444

X: @github

direct link

Domain: github.com

route-pattern/_view_fragments/voltron/pull_requests/show/:user_id/:repository/:id/pull_request_layout(.:format)
route-controllervoltron_pull_requests_fragments
route-actionpull_request_layout
fetch-noncev2:7b08a898-993a-6aa0-5aba-bb796b65fdcc
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA6F4:1C41B3:B41D69:FD9F9C:6A625912
html-safe-nonce5c2d6d5d8d963f655411633e619af99318eba3a6ea97f9b169f7d0060cb72c37
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNkY0OjFDNDFCMzpCNDFENjk6RkQ5RjlDOjZBNjI1OTEyIiwidmlzaXRvcl9pZCI6IjUzMzIxNDY1NDE5MzUzNTIwODIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac4286738ad813a779c6b1c341715c8ee83f880ccc2add7fd1fbe87bf3afef8e25
hovercard-subject-tagpull_request:3118380634
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/pull_requests_fragments/pull_request_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/voltron/pull_requests/show/python/mypy/20444/pull_request_layout
twitter:imagehttps://opengraph.githubassets.com/6b6afee9f432cd404a5d3ec1b5cc4d7c8ea9fd585fc2ad192f94a8443299c18c/python/mypy/pull/20444
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/6b6afee9f432cd404a5d3ec1b5cc4d7c8ea9fd585fc2ad192f94a8443299c18c/python/mypy/pull/20444
og:image:altThis PR aims to formalize the behavior of Literal? types (Instance with last_known_value) by treating them as-if they were AnyOf-types (see python/typing#566) For example, Literal["x"]? i...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamerandolf-scholz
hostnamegithub.com
expected-hostnamegithub.com
Noneb928dd27bb9305f313c737471c216297e218430ec505d064cf33d7d74af9bf89
turbo-cache-controlno-cache
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
release6f728c3f39985ee4d171ffdd5591d8d2652392d9
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/mypy/pull/20444#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fpull%2F20444
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fpull%2F20444
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fpull_requests_fragments%2Fpull_request_layout&source=header-repo&source_repo=python%2Fmypy
Reloadhttps://github.com/python/mypy/pull/20444
Reloadhttps://github.com/python/mypy/pull/20444
Reloadhttps://github.com/python/mypy/pull/20444
Please reload this pagehttps://github.com/python/mypy/pull/20444
python https://github.com/python
mypyhttps://github.com/python/mypy
Please reload this pagehttps://github.com/python/mypy/pull/20444
Notifications https://github.com/login?return_to=%2Fpython%2Fmypy
Fork 3.3k https://github.com/login?return_to=%2Fpython%2Fmypy
Star 20.5k https://github.com/login?return_to=%2Fpython%2Fmypy
Code https://github.com/python/mypy
Issues 2.7k https://github.com/python/mypy/issues
Pull requests 474 https://github.com/python/mypy/pulls
Actions https://github.com/python/mypy/actions
Projects https://github.com/python/mypy/projects
Wiki https://github.com/python/mypy/wiki
Security and quality 0 https://github.com/python/mypy/security
Insights https://github.com/python/mypy/pulse
Code https://github.com/python/mypy
Issues https://github.com/python/mypy/issues
Pull requests https://github.com/python/mypy/pulls
Actions https://github.com/python/mypy/actions
Projects https://github.com/python/mypy/projects
Wiki https://github.com/python/mypy/wiki
Security and quality https://github.com/python/mypy/security
Insights https://github.com/python/mypy/pulse
randolf-scholzhttps://github.com/randolf-scholz
python:masterhttps://github.com/python/mypy/tree/master
randolf-scholz:literals_as_anyof_typeshttps://github.com/randolf-scholz/mypy/tree/literals_as_anyof_types
Conversationhttps://github.com/python/mypy/pull/20444
Commits14 (14)https://github.com/python/mypy/pull/20444/commits
Checkshttps://github.com/python/mypy/pull/20444/checks
Files changedhttps://github.com/python/mypy/pull/20444/files
Improved Literal? typeshttps://github.com/python/mypy/pull/20444#top
randolf-scholzhttps://github.com/randolf-scholz
python:masterhttps://github.com/python/mypy/tree/master
randolf-scholz:literals_as_anyof_typeshttps://github.com/randolf-scholz/mypy/tree/literals_as_anyof_types
https://github.com/randolf-scholz
randolf-scholzhttps://github.com/randolf-scholz
Dec 19, 2025https://github.com/python/mypy/pull/20444#issue-3748391363
python/typing#566https://github.com/python/typing/issues/566
Specify behavior for Literal? types. #19625https://github.com/python/mypy/issues/19625
meet_types gives unexpected results when meeting literal and Instance #19560https://github.com/python/mypy/issues/19560
Regression: false positive avoid redundant cast with literal union #19055https://github.com/python/mypy/issues/19055
Please reload this pagehttps://github.com/python/mypy/pull/20444
https://github.com/randolf-scholz
better support for literal? typeshttps://github.com/python/mypy/pull/20444/commits/0e09a61203c8d3ba8ee91d83f6080cf8dda29a98
0e09a61https://github.com/python/mypy/pull/20444/commits/0e09a61203c8d3ba8ee91d83f6080cf8dda29a98
https://github.com/randolf-scholz
randolf-scholzhttps://github.com/randolf-scholz
Dec 19, 2025 https://github.com/python/mypy/pull/20444#ref-pullrequest-3300013521
Fix meet_types for literal and instance #19605 https://github.com/python/mypy/pull/19605
https://github.com/apps/github-actions
Sign in to viewhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fpull%2F20444
https://github.com/randolf-scholz
randolf-scholzhttps://github.com/randolf-scholz
December 20, 2025 13:22https://github.com/python/mypy/pull/20444#event-21684848214
https://github.com/randolf-scholz
randolf-scholzhttps://github.com/randolf-scholz
Dec 20, 2025https://github.com/python/mypy/pull/20444#issuecomment-3677830833
Please reload this pagehttps://github.com/python/mypy/pull/20444
Please reload this pagehttps://github.com/python/mypy/pull/20444
https://github.com/randolf-scholz
randolf-scholzhttps://github.com/randolf-scholz
December 21, 2025 12:26https://github.com/python/mypy/pull/20444#event-21690020840
https://github.com/randolf-scholz
randolf-scholzhttps://github.com/randolf-scholz
Dec 21, 2025 https://github.com/python/mypy/pull/20444#pullrequestreview-3601681855
View reviewed changes https://github.com/python/mypy/pull/20444/files/0e09a61203c8d3ba8ee91d83f6080cf8dda29a98
mypy/typeops.pyhttps://github.com/python/mypy/pull/20444/files/0e09a61203c8d3ba8ee91d83f6080cf8dda29a98#diff-1dce7e2a19559e2ff4e08fd46877b87c9cfec3cb5e6d465157788542948e11e4
randolf-scholzhttps://github.com/randolf-scholz
Dec 21, 2025https://github.com/python/mypy/pull/20444#discussion_r2637792302
Please reload this pagehttps://github.com/python/mypy/pull/20444
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/mypy/pull/20444
davidhalterhttps://github.com/davidhalter
Dec 21, 2025https://github.com/python/mypy/pull/20444#discussion_r2637798352
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/mypy/pull/20444
https://github.com/randolf-scholz
randolf-scholzhttps://github.com/randolf-scholz
Jan 10, 2026https://github.com/python/mypy/pull/20444#issuecomment-3733400529
python/typeshed#15160https://github.com/python/typeshed/pull/15160
Please reload this pagehttps://github.com/python/mypy/pull/20444
https://github.com/randolf-scholz
randolf-scholzhttps://github.com/randolf-scholz
Jan 16, 2026 https://github.com/python/mypy/pull/20444#ref-issue-3809565816
Misleading error message with dict.get like method. (polymorphic function with conflicting context) #20576 https://github.com/python/mypy/issues/20576
https://github.com/randolf-scholz
Merge branch 'master' into literals_as_anyof_typeshttps://github.com/python/mypy/pull/20444/commits/6101a57ff5eaf691a519b9e63244186316de0599
6101a57https://github.com/python/mypy/pull/20444/commits/6101a57ff5eaf691a519b9e63244186316de0599
https://github.com/apps/github-actions
Sign in to viewhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fpull%2F20444
https://github.com/randolf-scholz
randolf-scholzhttps://github.com/randolf-scholz
Jan 19, 2026 https://github.com/python/mypy/pull/20444#ref-issue-3696774317
str.split v. LiteralString false positive type error. facebook/pyrefly#1766 https://github.com/facebook/pyrefly/issues/1766
randolf-scholzhttps://github.com/randolf-scholz
February 2, 2026 21:06https://github.com/python/mypy/pull/20444#commits-pushed-76eb7ce
https://github.com/randolf-scholz
Merge branch 'master' into literals_as_anyof_typeshttps://github.com/python/mypy/pull/20444/commits/76eb7ceb5b8bec5990f70165b719d39aaa5beea1
76eb7cehttps://github.com/python/mypy/pull/20444/commits/76eb7ceb5b8bec5990f70165b719d39aaa5beea1
https://github.com/randolf-scholz
Merge branch 'master' into literals_as_anyof_typeshttps://github.com/python/mypy/pull/20444/commits/02607629480abc50de42bf9977feea26132a7bb1
0260762https://github.com/python/mypy/pull/20444/commits/02607629480abc50de42bf9977feea26132a7bb1
https://github.com/apps/github-actions
Sign in to viewhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fpull%2F20444
https://github.com/randolf-scholz
randolf-scholzhttps://github.com/randolf-scholz
February 3, 2026 08:53https://github.com/python/mypy/pull/20444#event-22490128258
https://github.com/randolf-scholz
randolf-scholzhttps://github.com/randolf-scholz
Feb 3, 2026https://github.com/python/mypy/pull/20444#issuecomment-3839965849
Please reload this pagehttps://github.com/python/mypy/pull/20444
randolf-scholzhttps://github.com/randolf-scholz
February 3, 2026 10:01https://github.com/python/mypy/pull/20444#commits-pushed-d7fe600
https://github.com/randolf-scholz
updated test-datahttps://github.com/python/mypy/pull/20444/commits/d7fe6001e6d0e5e26de5d34ceff3d1857522c22c
d7fe600https://github.com/python/mypy/pull/20444/commits/d7fe6001e6d0e5e26de5d34ceff3d1857522c22c
https://github.com/randolf-scholz
fixed incompatibility with FlipFlop test-casehttps://github.com/python/mypy/pull/20444/commits/80d2bed2c79c4ca9e3e1517a2c648172a018e0cd
80d2bedhttps://github.com/python/mypy/pull/20444/commits/80d2bed2c79c4ca9e3e1517a2c648172a018e0cd
https://github.com/apps/github-actions
Sign in to viewhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fpull%2F20444
https://github.com/randolf-scholz
added type hint for mypychttps://github.com/python/mypy/pull/20444/commits/96da68d2e4054f33a12bcdb109bddc91fa1f1907
96da68dhttps://github.com/python/mypy/pull/20444/commits/96da68d2e4054f33a12bcdb109bddc91fa1f1907
https://github.com/randolf-scholz
randolf-scholzhttps://github.com/randolf-scholz
Feb 3, 2026https://github.com/python/mypy/pull/20444#issuecomment-3840280121
Please reload this pagehttps://github.com/python/mypy/pull/20444
https://github.com/randolf-scholz
Sign in to viewhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fpull%2F20444
https://github.com/apps/github-actions
Sign in to viewhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fpull%2F20444
https://github.com/randolf-scholz
cleanup + fix meet with NamedTuplehttps://github.com/python/mypy/pull/20444/commits/377a0af66e9eb2deb723beba887a091c802dc5d0
377a0afhttps://github.com/python/mypy/pull/20444/commits/377a0af66e9eb2deb723beba887a091c802dc5d0
https://github.com/apps/github-actions
Sign in to viewhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fpull%2F20444
randolf-scholzhttps://github.com/randolf-scholz
February 3, 2026 13:01https://github.com/python/mypy/pull/20444#commits-pushed-cea2af9
https://github.com/randolf-scholz
rewrote ternary statement as separate returns for mypychttps://github.com/python/mypy/pull/20444/commits/cea2af9d6dab1ab5f127bf5a33a0503c2d50a58b
cea2af9https://github.com/python/mypy/pull/20444/commits/cea2af9d6dab1ab5f127bf5a33a0503c2d50a58b
https://github.com/randolf-scholz
Merge branch 'master' into literals_as_anyof_typeshttps://github.com/python/mypy/pull/20444/commits/ef22b6911cda2a53763ccf77e801f657adc8c641
ef22b69https://github.com/python/mypy/pull/20444/commits/ef22b6911cda2a53763ccf77e801f657adc8c641
https://github.com/apps/github-actions
Sign in to viewhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fpull%2F20444
https://github.com/randolf-scholz
explicit is None check for mypychttps://github.com/python/mypy/pull/20444/commits/f2b855c2c651e23a1c6f5102b00ee41544060d3c
f2b855chttps://github.com/python/mypy/pull/20444/commits/f2b855c2c651e23a1c6f5102b00ee41544060d3c
https://github.com/apps/github-actions
Sign in to viewhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fpull%2F20444
https://github.com/randolf-scholz
Merge branch 'master' into literals_as_anyof_typeshttps://github.com/python/mypy/pull/20444/commits/8d53181adf7563fc0222924b0caa838bc3c3560c
8d53181https://github.com/python/mypy/pull/20444/commits/8d53181adf7563fc0222924b0caa838bc3c3560c
https://github.com/apps/github-actions
Sign in to viewhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fpull%2F20444
https://github.com/randolf-scholz
randolf-scholzhttps://github.com/randolf-scholz
Mar 8, 2026 https://github.com/python/mypy/pull/20444#ref-pullrequest-3149539966
Remove list.__add__ overloads. python/typeshed#14282 https://github.com/python/typeshed/pull/14282
https://github.com/randolf-scholz
Merge branch 'master' into literals_as_anyof_typeshttps://github.com/python/mypy/pull/20444/commits/8dfa9d68d2cc94b4ea4962b390753de1d5f136ab
8dfa9d6https://github.com/python/mypy/pull/20444/commits/8dfa9d68d2cc94b4ea4962b390753de1d5f136ab
https://github.com/apps/github-actions
Sign in to viewhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fpull%2F20444
https://github.com/hauntsaninja
Merge branch 'master' into literals_as_anyof_typeshttps://github.com/python/mypy/pull/20444/commits/da5727b2d632ebfdc0626c6e8ab4256f4484530f
da5727bhttps://github.com/python/mypy/pull/20444/commits/da5727b2d632ebfdc0626c6e8ab4256f4484530f
https://github.com/apps/github-actions
github-actionshttps://github.com/apps/github-actions
Apr 15, 2026https://github.com/python/mypy/pull/20444#issuecomment-4256282522
mypy_primerhttps://github.com/hauntsaninja/mypy_primer
Please reload this pagehttps://github.com/python/mypy/pull/20444
https://github.co/hiddenchars
https://github.com/python/mypy/pull/{{ revealButtonHref }}
Sign up for freehttps://github.com/join?source=comment-repo
Sign in to commenthttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fpull%2F20444
https://github.com/davidhalter
davidhalter https://github.com/davidhalter
https://github.com/python/mypy/pull/20444/files/0e09a61203c8d3ba8ee91d83f6080cf8dda29a98
Specify behavior for Literal? types. https://github.com/python/mypy/issues/19625
meet_types gives unexpected results when meeting literal and Instance https://github.com/python/mypy/issues/19560
Regression: false positive avoid redundant cast with literal union https://github.com/python/mypy/issues/19055
Please reload this pagehttps://github.com/python/mypy/pull/20444
https://github.com/randolf-scholz
https://github.com/davidhalter
https://github.com/hauntsaninja
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.