Title: Match statement syntax error does not obey version guards · Issue #19923 · python/mypy · GitHub
Open Graph Title: Match statement syntax error does not obey version guards · Issue #19923 · python/mypy
X Title: Match statement syntax error does not obey version guards · Issue #19923 · python/mypy
Description: This phenomenon was originally discovered by @dmarteau in #19892. I wrote and ran the following two tests under Python 3.12 and mypy master (1.19.0+dev) and they succeeded. [case testUnreachableAfterToplevelAssertFlaggy] # flags: --pytho...
Open Graph Description: This phenomenon was originally discovered by @dmarteau in #19892. I wrote and ran the following two tests under Python 3.12 and mypy master (1.19.0+dev) and they succeeded. [case testUnreachableAft...
X Description: This phenomenon was originally discovered by @dmarteau in #19892. I wrote and ran the following two tests under Python 3.12 and mypy master (1.19.0+dev) and they succeeded. [case testUnreachableAft...
Opengraph URL: https://github.com/python/mypy/issues/19923
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Match statement syntax error does not obey version guards","articleBody":"This phenomenon was originally discovered by @dmarteau in https://github.com/python/mypy/issues/19892.\n\nI wrote and ran the following two tests under Python 3.12 and mypy master (1.19.0+dev) and they succeeded. \n> \n> ```py\n> [case testUnreachableAfterToplevelAssertFlaggy]\n> # flags: --python-version=3.9 --show-error-codes\n> # This test may false negative succeed if you are actually running python 3.9\n> import sys\n> reveal_type(0) # N: Revealed type is \"Literal[0]?\"\n> x: int | tuple[int] # E: X | Y syntax for unions requires Python 3.10 [syntax]\n> \"a\"+1 # E: Unsupported operand types for + (\"str\" and \"int\") [operator]\n> assert sys.version_info > (3,9)\n> reveal_type('') # No error here :-)\n> x: int | tuple[int] # a little 3.10 syntax to check\n> [builtins fixtures/ops.pyi]\n> \n> [case testUnreachableAfterToplevelAssertConfigy]\n> # This test may false negative succeed if you are act>\n> # flags: --config-file=tmp/foo.ini --show-error-codes\n> import sys\n> reveal_type(0) # N: Revealed type is \"Literal[0]?\"\n> x: int | tuple[int] # E: X | Y syntax for unions requires Python 3.10 [syntax]\n> \"a\"+1 # E: Unsupported operand types for + (\"str\" and \"int\") [operator]\n> assert sys.version_info > (3,9)\n> reveal_type('') # No error here :-)\n> x: int | tuple[int] # a little 3.10 syntax to check\n> \n> [file foo.ini]\n> \\[mypy]\n> python_version=3.9\n> \n> [builtins fixtures/ops.pyi]\n> ```\n\nHowever, swapping in a match statement instead of a union bar **gets rid of all the other errors** and produces\n\n```\nerror: Pattern matching is only supported in Python 3.10 and greater [syntax]\n```\n\nWeird!","author":{"url":"https://github.com/wyattscarpenter","@type":"Person","name":"wyattscarpenter"},"datePublished":"2025-09-24T19:35:24Z","url":"https://github.com/python/mypy/issues/19923"}
| 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:e488d04b-e506-7539-fbdc-f104c02f2577 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A400:39E772:2EE0DD:3FE2DC:6B006A5A |
| html-safe-nonce | 8ac7706ccddabe37203d306b0d61b6ed45ee40d1527d046d8b8dc81f1a7c6817 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNDAwOjM5RTc3MjoyRUUwREQ6M0ZFMkRDOjZCMDA2QTVBIiwidmlzaXRvcl9pZCI6IjEzMDA5OTQ1MjQwMjEwMjUzNzAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 270b2105e2eb3eaf6bf08bbdca928c37d7e878632e1364f1415d377f6ad94b32 |
| hovercard-subject-tag | issue:3450687200 |
| 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/19923/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b4cd23ed5ffe91a878bc1d249be4d16801194dd9ef130551fb5eadf8feead40b/python/mypy/issues/19923 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b4cd23ed5ffe91a878bc1d249be4d16801194dd9ef130551fb5eadf8feead40b/python/mypy/issues/19923 |
| og:image:alt | This phenomenon was originally discovered by @dmarteau in #19892. I wrote and ran the following two tests under Python 3.12 and mypy master (1.19.0+dev) and they succeeded. [case testUnreachableAft... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | wyattscarpenter |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6527e91c60c0b29d16606ff32ac5df8ecdc37a2a62205ea057a14d7762c870fa |
| 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 | 46f1cd2ae3cd8ae1a81019b5d619742e76f13bbd |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width