Title: `class S(tuple[*tuple[()]])` crashes mypy · Issue #19105 · python/mypy · GitHub
Open Graph Title: `class S(tuple[*tuple[()]])` crashes mypy · Issue #19105 · python/mypy
X Title: `class S(tuple[*tuple[()]])` crashes mypy · Issue #19105 · python/mypy
Description: class S(tuple[*tuple[()]]): ... mypy 1.15 stacktrace (mypy-play): Traceback (most recent call last): File "
Open Graph Description: class S(tuple[*tuple[()]]): ... mypy 1.15 stacktrace (mypy-play): Traceback (most recent call last): File "
X Description: class S(tuple[*tuple[()]]): ... mypy 1.15 stacktrace (mypy-play): Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen ru...
Opengraph URL: https://github.com/python/mypy/issues/19105
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`class S(tuple[*tuple[()]])` crashes mypy","articleBody":"```py\nclass S(tuple[*tuple[()]]): ...\n```\n\nmypy 1.15 stacktrace ([mypy-play](https://mypy-play.net/?mypy=latest&python=3.13&gist=c73a206345ae50e7d35d512d773830ba)):\n\n```pytb\nTraceback (most recent call last):\n File \"\u003cfrozen runpy>\", line 198, in _run_module_as_main\n File \"\u003cfrozen runpy>\", line 88, in _run_code\n File \"/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/__main__.py\", line 37, in \u003cmodule>\n console_entry()\n File \"/layers/google.python.pip/pip/lib/python3.12/site-packages/mypy/__main__.py\", line 15, in console_entry\n main()\n File \"mypy/main.py\", line 119, in main\n File \"mypy/main.py\", line 203, in run_build\n File \"mypy/build.py\", line 191, in build\n File \"mypy/build.py\", line 267, in _build\n File \"mypy/build.py\", line 2937, in dispatch\n File \"mypy/build.py\", line 3335, in process_graph\n File \"mypy/build.py\", line 3430, in process_stale_scc\n File \"mypy/semanal_main.py\", line 97, in semantic_analysis_for_scc\n File \"mypy/semanal.py\", line 7621, in apply_semantic_analyzer_patches\n File \"mypy/semanal.py\", line 2587, in \u003clambda>\n File \"mypy/semanal_shared.py\", line 305, in calculate_tuple_fallback\nNotImplementedError\n```\n\nand on current `master` ([mypy-play](https://mypy-play.net/?mypy=master&python=3.13&gist=c73a206345ae50e7d35d512d773830ba))\n\n```pytb\nTraceback (most recent call last):\n File \"\u003cfrozen runpy>\", line 198, in _run_module_as_main\n File \"\u003cfrozen runpy>\", line 88, in _run_code\n File \"mypy/__main__.py\", line 37, in \u003cmodule>\n console_entry()\n File \"mypy/__main__.py\", line 15, in console_entry\n main()\n File \"mypy/main.py\", line 127, in main\n res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"mypy/main.py\", line 211, in run_build\n res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"mypy/build.py\", line 191, in build\n result = _build(\n ^^^^^^^\n File \"mypy/build.py\", line 267, in _build\n graph = dispatch(sources, manager, stdout)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"mypy/build.py\", line 2939, in dispatch\n process_graph(graph, manager)\n File \"mypy/build.py\", line 3337, in process_graph\n process_stale_scc(graph, scc, manager)\n File \"mypy/build.py\", line 3432, in process_stale_scc\n mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)\n File \"mypy/semanal_main.py\", line 99, in semantic_analysis_for_scc\n apply_semantic_analyzer_patches(patches)\n File \"mypy/semanal.py\", line 7740, in apply_semantic_analyzer_patches\n patch_func()\n File \"mypy/semanal.py\", line 2630, in \u003clambda>\n self.schedule_patch(PRIORITY_FALLBACKS, lambda: calculate_tuple_fallback(base))\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"mypy/semanal_shared.py\", line 305, in calculate_tuple_fallback\n raise NotImplementedError\n```\n\n\n---\n\nanother way to trigger this crash is through a typo in the variadic type parameter name:\n\n```pyi\nclass MyTuple[*Ts](tuple[*_Ts]): ... # oh no a typo\n```\n\nthis produces an identical stacktrace ([mypy-play](https://mypy-play.net/?mypy=latest&python=3.13&gist=d690a693b10435804af10f9ed9a270c4))\n\n---\n\nsome observations:\n\n- it doesn't matter if `typing.Unpack` is used instead of `*`\n- I checked all versions from 1.9.0-master, and all crash in the same way\n- `class S(tuple[()]): ...` does not cause a crash \n (although `S()` is [revealed as](https://mypy-play.net/?mypy=latest&python=3.13&gist=08f4af8a360ea5b743c0c49bce719052) `tuple[(), fallback=__main__.S]`, which is kinda sus)\n- in case you didn't notice; the first example is valid at runtime, the second isn't\n- my ear is a bit itchy\n\nAnd it's probably not what you want to hear, but it might be relevant info, so I'll carefully whisper it: \u003csub>Pyright does not have this problem ([playground 1](https://pyright-play.net/?pythonVersion=3.14&strict=true&code=MYGwhgzhAEDKAUAXArgBxAUwNoCoXu3gEoBdEogLmgDpaAoIA), [playground 2](https://pyright-play.net/?pythonVersion=3.14&strict=true&code=MYGwhgzhAECyCeAVArgBxAUwNoCpEQF0AKAFzU1wH18CBKALmgDoXpoBiaAewAtoA7LtDDQS8VFwBQQA)), and the same goes for ty ([playground 1](https://play.ty.dev/93a8653a-9a6e-4a45-8016-ecade3dd638e), [playground 2](https://play.ty.dev/7aff606b-a731-4958-8b4b-80f06e286c10))\u003c/sub>\n\n---\n\nref: https://github.com/python/mypy/pull/19100#issuecomment-2889099140","author":{"url":"https://github.com/jorenham","@type":"Person","name":"jorenham"},"datePublished":"2025-05-18T17:46:14Z","url":"https://github.com/python/mypy/issues/19105"}
| 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:dbc799c8-97b0-a51d-574a-08288a8f61fd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C006:177D5B:32184E3:424E8B3:6B0032D3 |
| html-safe-nonce | 797810e74e7f807f2d464314b42dba8418d599d3488c6cedca16d951ff38b7ad |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMDA2OjE3N0Q1QjozMjE4NEUzOjQyNEU4QjM6NkIwMDMyRDMiLCJ2aXNpdG9yX2lkIjoiMTQxODMxNjc4MjY4NjQ1MDM4NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b73627721754c0c447e113a5e89a5d6d600e8756e51784e0425b3580e0abe1fa |
| hovercard-subject-tag | issue:3071950726 |
| 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/19105/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2e7d6e9d472a470c76f6a2964c0d775f5bd296ea9617b0c8176b50f10b534d7b/python/mypy/issues/19105 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2e7d6e9d472a470c76f6a2964c0d775f5bd296ea9617b0c8176b50f10b534d7b/python/mypy/issues/19105 |
| og:image:alt | class S(tuple[*tuple[()]]): ... mypy 1.15 stacktrace (mypy-play): Traceback (most recent call last): File " |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jorenham |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width