René's URL Explorer Experiment


Title: Improve match statement union narrowing/inference by bergkvist · Pull Request #17600 · python/mypy · GitHub

Open Graph Title: Improve match statement union narrowing/inference by bergkvist · Pull Request #17600 · python/mypy

X Title: Improve match statement union narrowing/inference by bergkvist · Pull Request #17600 · python/mypy

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

Open Graph Description: Improve inference/narrowing support for union types in match statements. Fixes #17549 Before: var: tuple[int, int] | tuple[str, str] # TODO: we can infer better here. match var: case (42, a): ...

X Description: Improve inference/narrowing support for union types in match statements. Fixes #17549 Before: var: tuple[int, int] | tuple[str, str] # TODO: we can infer better here. match var: case (42, a): ...

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

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:0795c85a-4856-394f-a77d-f6e2c06fd311
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id8DF8:21D998:F575B6:166158F:6A5758BC
html-safe-nonce4eca61477b52b3e53f09d6f8a9aa5144e6f6ba7310f342a5b43416d283face1b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4REY4OjIxRDk5ODpGNTc1QjY6MTY2MTU4Rjo2QTU3NThCQyIsInZpc2l0b3JfaWQiOiIxMzI0NjQwNTAwODE3ODExNjQ0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacbe8ae7bcb1df4bf44e02b4ec9bfb0bb3c69a4ba85b21da78f368f13fa4522df0
hovercard-subject-tagpull_request:1990675801
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/17600/pull_request_layout
twitter:imagehttps://opengraph.githubassets.com/a717518a0ba53a773b34b0973743589be89d0e9e18ff4a6d98ad1a999e8c2d20/python/mypy/pull/17600
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a717518a0ba53a773b34b0973743589be89d0e9e18ff4a6d98ad1a999e8c2d20/python/mypy/pull/17600
og:image:altImprove inference/narrowing support for union types in match statements. Fixes #17549 Before: var: tuple[int, int] | tuple[str, str] # TODO: we can infer better here. match var: case (42, a): ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamebergkvist
hostnamegithub.com
expected-hostnamegithub.com
None4e7a7296a3830877cf21a6ad2a972c9e618a48915e03966cf0c53eb08e5aad98
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
release602250ea3b6dd8302a7220ef98adb828dbc807e4
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/mypy/pull/17600#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fpull%2F17600
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
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%2F17600
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/17600
Reloadhttps://github.com/python/mypy/pull/17600
Reloadhttps://github.com/python/mypy/pull/17600
Please reload this pagehttps://github.com/python/mypy/pull/17600
python https://github.com/python
mypyhttps://github.com/python/mypy
Please reload this pagehttps://github.com/python/mypy/pull/17600
Notifications https://github.com/login?return_to=%2Fpython%2Fmypy
Fork 3.2k 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 464 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
bergkvisthttps://github.com/bergkvist
python:masterhttps://github.com/python/mypy/tree/master
bergkvist:tobias/match-union-narrowinghttps://github.com/bergkvist/mypy/tree/tobias/match-union-narrowing
Conversationhttps://github.com/python/mypy/pull/17600
Commits9 (9)https://github.com/python/mypy/pull/17600/commits
Checkshttps://github.com/python/mypy/pull/17600/checks
Files changedhttps://github.com/python/mypy/pull/17600/files
Improve match statement union narrowing/inferencehttps://github.com/python/mypy/pull/17600#top
bergkvisthttps://github.com/bergkvist
python:masterhttps://github.com/python/mypy/tree/master
bergkvist:tobias/match-union-narrowinghttps://github.com/bergkvist/mypy/tree/tobias/match-union-narrowing
https://github.com/bergkvist
bergkvisthttps://github.com/bergkvist
Jul 27, 2024https://github.com/python/mypy/pull/17600#issue-2433657926
Please reload this pagehttps://github.com/python/mypy/pull/17600
#17549https://github.com/python/mypy/issues/17549
Support for python 3.10 match statement #10191https://github.com/python/mypy/pull/10191
Please reload this pagehttps://github.com/python/mypy/pull/17600
bergkvisthttps://github.com/bergkvist
July 28, 2024 01:18https://github.com/python/mypy/pull/17600#commits-pushed-100c659
https://github.com/bergkvist
Improve match statement union narrowing/inferencehttps://github.com/python/mypy/pull/17600/commits/100c659683024fa0e589c9341230246594381a45
100c659https://github.com/python/mypy/pull/17600/commits/100c659683024fa0e589c9341230246594381a45
https://github.com/bergkvist
Fix lint errors: Use get_proper_type and rename captures to union_cap…https://github.com/python/mypy/pull/17600/commits/c62587aef2b0362609e31919e1baed2f76372db6
c62587ahttps://github.com/python/mypy/pull/17600/commits/c62587aef2b0362609e31919e1baed2f76372db6
https://github.com/apps/github-actions
Sign in to viewhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fpull%2F17600
https://github.com/Hnasar
Hnasarhttps://github.com/Hnasar
Aug 8, 2024 https://github.com/python/mypy/pull/17600#pullrequestreview-2226808081
View reviewed changes https://github.com/python/mypy/pull/17600/files/c62587aef2b0362609e31919e1baed2f76372db6
Hnasarhttps://github.com/Hnasar
https://github.com/python/mypy/pull/17600#pullrequestreview-2226808081
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
https://github.com/python/mypy/issues?q=sort%3Aupdated-desc+is%3Aopen+label%3Atopic-match-statementhttps://github.com/python/mypy/issues?q=sort%3Aupdated-desc+is%3Aopen+label%3Atopic-match-statement
Please reload this pagehttps://github.com/python/mypy/pull/17600
mypy/checkpattern.pyhttps://github.com/python/mypy/pull/17600/files/c62587aef2b0362609e31919e1baed2f76372db6#diff-899f1e6b7a4d5a6697e7a47731ebcf92a1ce845b5f5fc0b70e3f7ebbef10d7c1
Please reload this pagehttps://github.com/python/mypy/pull/17600
https://github.com/bergkvist
https://github.com/Hnasar
Save a function call by storing length of union itemshttps://github.com/python/mypy/pull/17600/commits/e418d98d2edfc5858b0503106292597829965555
e418d98https://github.com/python/mypy/pull/17600/commits/e418d98d2edfc5858b0503106292597829965555
https://github.com/apps/github-actions
Sign in to viewhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fpull%2F17600
https://github.com/bergkvist
bergkvisthttps://github.com/bergkvist
Aug 11, 2024https://github.com/python/mypy/pull/17600#issuecomment-2282752639
https://github.com/python/mypy/issues?q=sort%3Aupdated-desc+is%3Aopen+label%3Atopic-match-statementhttps://github.com/python/mypy/issues?q=sort%3Aupdated-desc+is%3Aopen+label%3Atopic-match-statement
Unable to narrow the type of a tagged union when using a match statement #15190https://github.com/python/mypy/issues/15190
Type is not being narrowed properly in match statement #17549https://github.com/python/mypy/issues/17549
Please reload this pagehttps://github.com/python/mypy/pull/17600
bergkvisthttps://github.com/bergkvist
August 18, 2024 02:27https://github.com/python/mypy/pull/17600#commits-pushed-e85e8d4
https://github.com/bergkvist
Refactor: Use UnionType.make_union(..)https://github.com/python/mypy/pull/17600/commits/e85e8d464ca2b805672db8ad772d3b6ed4ce6adc
e85e8d4https://github.com/python/mypy/pull/17600/commits/e85e8d464ca2b805672db8ad772d3b6ed4ce6adc
https://github.com/bergkvist
Use is_uninhabited(typ) instead of isinstance(typ, UninhabitedType)https://github.com/python/mypy/pull/17600/commits/34585b6f7c6deb70f8ddfb2de48fd59d180dc014
34585b6https://github.com/python/mypy/pull/17600/commits/34585b6f7c6deb70f8ddfb2de48fd59d180dc014
https://github.com/apps/github-actions
Sign in to viewhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fpull%2F17600
https://github.com/hjwp
hjwphttps://github.com/hjwp
Aug 21, 2024https://github.com/python/mypy/pull/17600#issuecomment-2301688016
#16835https://github.com/python/mypy/issues/16835
Please reload this pagehttps://github.com/python/mypy/pull/17600
https://github.com/bergkvist
bergkvisthttps://github.com/bergkvist
Aug 21, 2024https://github.com/python/mypy/pull/17600#issuecomment-2301794315
#16835https://github.com/python/mypy/issues/16835
Please reload this pagehttps://github.com/python/mypy/pull/17600
https://github.com/bergkvist
Narrow rest_type based on match type and current_typehttps://github.com/python/mypy/pull/17600/commits/cb6fa03b443f82fdec7a4d80ae1c02bda92ecdca
cb6fa03https://github.com/python/mypy/pull/17600/commits/cb6fa03b443f82fdec7a4d80ae1c02bda92ecdca
https://github.com/apps/github-actions
Sign in to viewhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fpull%2F17600
bergkvisthttps://github.com/bergkvist
September 2, 2024 01:49https://github.com/python/mypy/pull/17600#commits-pushed-4d28adf
https://github.com/bergkvist
Fix no-redef lint for rest_typehttps://github.com/python/mypy/pull/17600/commits/4d28adf498e20460b75f7f8fc4f25531c34fea8f
4d28adfhttps://github.com/python/mypy/pull/17600/commits/4d28adf498e20460b75f7f8fc4f25531c34fea8f
https://github.com/marketplace/pre-commit-ci
[pre-commit.ci] auto fixes from pre-commit.com hookshttps://github.com/python/mypy/pull/17600/commits/92d3c91aaf2757706f9ef923650eb342d19af2fb
92d3c91https://github.com/python/mypy/pull/17600/commits/92d3c91aaf2757706f9ef923650eb342d19af2fb
https://pre-commit.cihttps://pre-commit.ci
https://github.com/apps/github-actions
Sign in to viewhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fmypy%2Fpull%2F17600
https://github.com/distrame
distramehttps://github.com/distrame
Dec 25, 2024 https://github.com/python/mypy/pull/17600#ref-issue-2421022521
Type is not being narrowed properly in match statement #17549 https://github.com/python/mypy/issues/17549
https://github.com/smurzin
smurzinhttps://github.com/smurzin
Jan 22, 2025https://github.com/python/mypy/pull/17600#issuecomment-2607823356
@bergkvisthttps://github.com/bergkvist
@Hnasarhttps://github.com/Hnasar
Please reload this pagehttps://github.com/python/mypy/pull/17600
https://github.com/lordmauve
lordmauvehttps://github.com/lordmauve
Apr 8, 2025https://github.com/python/mypy/pull/17600#issuecomment-2786948864
Please reload this pagehttps://github.com/python/mypy/pull/17600
Please reload this pagehttps://github.com/python/mypy/pull/17600
https://github.com/Hnasar
Hnasarhttps://github.com/Hnasar
Apr 9, 2025https://github.com/python/mypy/pull/17600#issuecomment-2791180222
@bergkvisthttps://github.com/bergkvist
Please reload this pagehttps://github.com/python/mypy/pull/17600
https://github.com/hauntsaninja
hauntsaninjahttps://github.com/hauntsaninja
Aug 3, 2025 https://github.com/python/mypy/pull/17600#pullrequestreview-3082404638
View reviewed changes https://github.com/python/mypy/pull/17600/files/92d3c91aaf2757706f9ef923650eb342d19af2fb
hauntsaninjahttps://github.com/hauntsaninja
https://github.com/python/mypy/pull/17600#pullrequestreview-3082404638
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/mypy/pull/17600
mypy/checkpattern.pyhttps://github.com/python/mypy/pull/17600/files/92d3c91aaf2757706f9ef923650eb342d19af2fb#diff-899f1e6b7a4d5a6697e7a47731ebcf92a1ce845b5f5fc0b70e3f7ebbef10d7c1
hauntsaninjahttps://github.com/hauntsaninja
Aug 3, 2025https://github.com/python/mypy/pull/17600#discussion_r2250179422
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/mypy/pull/17600
mypy/checkpattern.pyhttps://github.com/python/mypy/pull/17600/files/92d3c91aaf2757706f9ef923650eb342d19af2fb#diff-899f1e6b7a4d5a6697e7a47731ebcf92a1ce845b5f5fc0b70e3f7ebbef10d7c1
hauntsaninjahttps://github.com/hauntsaninja
Aug 3, 2025https://github.com/python/mypy/pull/17600#discussion_r2250179484
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/python/mypy/pull/17600
https://github.com/hauntsaninja
hauntsaninjahttps://github.com/hauntsaninja
upnext https://github.com/python/mypy/issues?q=state%3Aopen%20label%3Aupnext
Aug 3, 2025https://github.com/python/mypy/pull/17600#event-18959811876
https://github.com/hauntsaninja
Merge branch 'master' into tobias/match-union-narrowinghttps://github.com/python/mypy/pull/17600/commits/9b4b1d4a7343e5105946b5eb7db51a18f424badf
9b4b1d4https://github.com/python/mypy/pull/17600/commits/9b4b1d4a7343e5105946b5eb7db51a18f424badf
https://github.com/apps/github-actions
github-actionshttps://github.com/apps/github-actions
Jan 18, 2026https://github.com/python/mypy/pull/17600#issuecomment-3764905790
mypy_primerhttps://github.com/hauntsaninja/mypy_primer
Please reload this pagehttps://github.com/python/mypy/pull/17600
https://github.com/hauntsaninja
hauntsaninjahttps://github.com/hauntsaninja
Feb 5, 2026 https://github.com/python/mypy/pull/17600#ref-pullrequest-3900233979
Further improve match statement narrowing against unions #20744 https://github.com/python/mypy/pull/20744
https://github.com/hauntsaninja
hauntsaninjahttps://github.com/hauntsaninja
#20744 https://github.com/python/mypy/pull/20744
Feb 11, 2026https://github.com/python/mypy/pull/17600#event-22714398454
pullhttps://github.com/apps/pull
Feb 11, 2026 https://github.com/python/mypy/pull/17600#ref-commit-9752e19
https://github.com/hauntsaninja
Further improve match statement narrowing against unions (https://github.com/LadyK-21/mypy/commit/9752e1968e9224d2ead4f0cdfd5ff3791ab21b35
python#20744https://github.com/python/mypy/pull/20744
)https://github.com/LadyK-21/mypy/commit/9752e1968e9224d2ead4f0cdfd5ff3791ab21b35
9752e19https://github.com/LadyK-21/mypy/commit/9752e1968e9224d2ead4f0cdfd5ff3791ab21b35
python#19600https://github.com/python/mypy/pull/19600
python#19600https://github.com/python/mypy/pull/19600
python#15190https://github.com/python/mypy/issues/15190
python#17549https://github.com/python/mypy/issues/17549
python#17600https://github.com/python/mypy/pull/17600
python#18039https://github.com/python/mypy/issues/18039
python#19081https://github.com/python/mypy/issues/19081
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%2F17600
https://github.com/hauntsaninja
hauntsaninja https://github.com/hauntsaninja
https://github.com/python/mypy/pull/17600/files/92d3c91aaf2757706f9ef923650eb342d19af2fb
https://github.com/Hnasar
Hnasar https://github.com/Hnasar
https://github.com/python/mypy/pull/17600/files/c62587aef2b0362609e31919e1baed2f76372db6
upnext https://github.com/python/mypy/issues?q=state%3Aopen%20label%3Aupnext
Type is not being narrowed properly in match statement https://github.com/python/mypy/issues/17549
Please reload this pagehttps://github.com/python/mypy/pull/17600
https://github.com/bergkvist
https://github.com/hjwp
https://github.com/smurzin
https://github.com/lordmauve
https://github.com/Hnasar
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.