Title: unpacked two tuples in `NewType` crashes with `AssertionError` · Issue #21237 · python/mypy · GitHub
Open Graph Title: unpacked two tuples in `NewType` crashes with `AssertionError` · Issue #21237 · python/mypy
X Title: unpacked two tuples in `NewType` crashes with `AssertionError` · Issue #21237 · python/mypy
Description: Crash Report I'm trying to derive (via unpacking) a tuple wrapped in NewType from another one and ended-up crashing mypy. Traceback ./main.py:4: error: INTERNAL ERROR -- Please try using mypy master on GitHub: https://mypy.readthedocs.io...
Open Graph Description: Crash Report I'm trying to derive (via unpacking) a tuple wrapped in NewType from another one and ended-up crashing mypy. Traceback ./main.py:4: error: INTERNAL ERROR -- Please try using mypy maste...
X Description: Crash Report I'm trying to derive (via unpacking) a tuple wrapped in NewType from another one and ended-up crashing mypy. Traceback ./main.py:4: error: INTERNAL ERROR -- Please try using mypy m...
Opengraph URL: https://github.com/python/mypy/issues/21237
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"unpacked two tuples in `NewType` crashes with `AssertionError`","articleBody":"\u003c!--\n Use this form only if mypy reports an \"INTERNAL ERROR\" and/or gives a traceback.\n Please include the traceback and all other messages below (use `mypy --show-traceback`).\n-->\n\n**Crash Report**\n\nI'm trying to derive (via unpacking) a tuple wrapped in `NewType` from another one and ended-up crashing mypy.\n\n**Traceback**\n\n```python-traceback\n./main.py:4: error: INTERNAL ERROR -- Please try using mypy master on GitHub:\nhttps://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build\nPlease report a bug at https://github.com/python/mypy/issues\nversion: 2.0.0+dev.d0f55505ed6ac60e5917b5943534228f864fb6a6\n./main.py:4: note: use --pdb to drop into pdb\nTraceback (most recent call last):\n File \"/home/tharvik/tmp/mypy-crash/.venv/bin/mypy\", line 10, in \u003cmodule>\n sys.exit(console_entry())\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/__main__.py\", line 15, in console_entry\n main()\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/main.py\", line 143, in main\n res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/main.py\", line 233, in run_build\n res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/build.py\", line 421, in build\n result = build_inner(\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/build.py\", line 529, in build_inner\n graph = dispatch(sources, manager, stdout, connect_threads)\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/build.py\", line 4012, in dispatch\n process_graph(graph, manager)\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/build.py\", line 4476, in process_graph\n done, still_working, results = manager.wait_for_done(graph)\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/build.py\", line 1389, in wait_for_done\n process_stale_scc(graph, next_scc, self)\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/build.py\", line 4650, in process_stale_scc\n graph[id].type_check_first_pass()\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/build.py\", line 3271, in type_check_first_pass\n self.type_checker().check_first_pass(recurse_into_functions=recurse_into_functions)\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/checker.py\", line 537, in check_first_pass\n self.accept(d)\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/checker.py\", line 648, in accept\n stmt.accept(self)\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/nodes.py\", line 1810, in accept\n return visitor.visit_expression_stmt(self)\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/checker.py\", line 5000, in visit_expression_stmt\n expr_type = self.expr_checker.accept(s.expr, allow_none_return=True, always_allow_any=True)\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/checkexpr.py\", line 6131, in accept\n typ = self.visit_call_expr(node, allow_none_return=True)\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/checkexpr.py\", line 502, in visit_call_expr\n return self.visit_call_expr_inner(e, allow_none_return=allow_none_return)\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/checkexpr.py\", line 639, in visit_call_expr_inner\n ret_type = self.check_call_expr_with_callee_type(\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/checkexpr.py\", line 1489, in check_call_expr_with_callee_type\n ret_type, callee_type = self.check_call(\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/checkexpr.py\", line 1582, in check_call\n return self.check_callable_call(\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/checkexpr.py\", line 1793, in check_callable_call\n arg_types = self.infer_arg_types_in_context(callee, args, arg_kinds, formal_to_actual)\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/checkexpr.py\", line 2012, in infer_arg_types_in_context\n res.append(self.accept(arg, ctx))\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/checkexpr.py\", line 6188, in accept\n typ = self.accept_maybe_cache(node, type_context=type_context)\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/checkexpr.py\", line 6223, in accept_maybe_cache\n typ = node.accept(self)\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/nodes.py\", line 2936, in accept\n return visitor.visit_tuple_expr(self)\n ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/checkexpr.py\", line 5297, in visit_tuple_expr\n if isinstance(type_context, TupleType) and self.tuple_context_matches(e, type_context):\n ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/checkexpr.py\", line 5266, in tuple_context_matches\n ctx_unpack_index = find_unpack_in_list(ctx.items)\n File \"/home/tharvik/tmp/mypy-crash/.venv/lib/python3.13/site-packages/mypy/types.py\", line 4192, in find_unpack_in_list\n assert old_index is None\n ^^^^^^^^^^^^^^^^^\nAssertionError\n```\n\n**To Reproduce**\n\nhttps://mypy-play.net/?gist=201fe8d4446594b2b70b80c932b4ce0b\n\n**Your Environment**\n\n\u003c!-- Include as many relevant details about the environment you experienced the bug in -->\n\n- Mypy version used: HEAD\n- Python version used: 3.13.12\n- Operating system and version: Gentoo/Linux, n/a","author":{"url":"https://github.com/tharvik","@type":"Person","name":"tharvik"},"datePublished":"2026-04-15T15:14:30Z","url":"https://github.com/python/mypy/issues/21237"}
| 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:14697222-6609-1ee2-5242-cab2ffc0bd68 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8CE4:2C3D4F:4001E4:55F77E:6B002AB0 |
| html-safe-nonce | 894a3c8480f5cc95c3004d8e2e1781e8bb83793775f045dcd49681bd5dcb0f89 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Q0U0OjJDM0Q0Rjo0MDAxRTQ6NTVGNzdFOjZCMDAyQUIwIiwidmlzaXRvcl9pZCI6IjgyMDU5NjEwMzQzMTQyOTU5ODQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 50ced6e1b1e5cef6901c4970e2a514d7d6f38370cf9b88773ad8d53c9e8005c6 |
| hovercard-subject-tag | issue:4269890976 |
| 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/21237/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bb0b9f213d9fcc4d05d0a6725cdf40505896826515ddd61a322cd15a321c910e/python/mypy/issues/21237 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bb0b9f213d9fcc4d05d0a6725cdf40505896826515ddd61a322cd15a321c910e/python/mypy/issues/21237 |
| og:image:alt | Crash Report I'm trying to derive (via unpacking) a tuple wrapped in NewType from another one and ended-up crashing mypy. Traceback ./main.py:4: error: INTERNAL ERROR -- Please try using mypy maste... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tharvik |
| 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