Title: Mypy crashes on async tuple to tuple assignment · Issue #19920 · python/mypy · GitHub
Open Graph Title: Mypy crashes on async tuple to tuple assignment · Issue #19920 · python/mypy
X Title: Mypy crashes on async tuple to tuple assignment · Issue #19920 · python/mypy
Description: Crash Report We got a tuple to tuple assignment with asyncio.gather, which crashes mypy, it looks like this: tab_content: PriceCombinedDBAccessTabContentDto price_region_stats: PriceRegionStats ( # < Error points to this line, this is li...
Open Graph Description: Crash Report We got a tuple to tuple assignment with asyncio.gather, which crashes mypy, it looks like this: tab_content: PriceCombinedDBAccessTabContentDto price_region_stats: PriceRegionStats ( #...
X Description: Crash Report We got a tuple to tuple assignment with asyncio.gather, which crashes mypy, it looks like this: tab_content: PriceCombinedDBAccessTabContentDto price_region_stats: PriceRegionStats ( #...
Opengraph URL: https://github.com/python/mypy/issues/19920
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Mypy crashes on async tuple to tuple assignment","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\nWe got a tuple to tuple assignment with asyncio.gather, which crashes mypy, it looks like this:\n```py\ntab_content: PriceCombinedDBAccessTabContentDto\nprice_region_stats: PriceRegionStats\n\n( # \u003c Error points to this line, this is line 70\n price_data,\n tab_content,\n all_price_regions,\n all_prof_role_groups,\n price_region_stats,\n has_civ_service,\n) = await asyncio.gather(\n get_price_data(handler, TabName.COMBINED_DBACCESS, price_description, backoffice_employer_id, session),\n get_price_tab_content(http_client, config, TabName.COMBINED_DBACCESS, backoffice_employer_id),\n get_all_price_regions(handler),\n get_all_prof_role_groups(handler),\n get_price_regions_stats(http_client, config),\n check_employer_has_service_no_handler(\n http_client, config, employer_id_or_backoffice_employer_id, ProductItemCode.ContactsView\n ),\n)\n```\n\n**Traceback**\n\n```python-traceback\nxhh/pages/price/combined_dbaccess.py:70: 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: 1.19.0+dev.354bea6352ee7a38b05e2f42c874e7d1f7bf557a\nTraceback (most recent call last):\n File \"/Users/gooverdian/Projects/xhh/.venv/bin/mypy\", line 8, in \u003cmodule>\n sys.exit(console_entry())\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/__main__.py\", line 15, in console_entry\n main()\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/main.py\", line 127, in main\n res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/main.py\", line 211, in run_build\n res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/build.py\", line 196, in build\n result = _build(\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/build.py\", line 272, in _build\n graph = dispatch(sources, manager, stdout)\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/build.py\", line 2946, in dispatch\n process_graph(graph, manager)\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/build.py\", line 3346, in process_graph\n process_stale_scc(graph, scc, manager)\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/build.py\", line 3447, in process_stale_scc\n graph[id].type_check_first_pass()\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/build.py\", line 2325, in type_check_first_pass\n self.type_checker().check_first_pass()\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/checker.py\", line 524, in check_first_pass\n self.accept(d)\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/checker.py\", line 635, in accept\n stmt.accept(self)\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/nodes.py\", line 1127, in accept\n return visitor.visit_decorator(self)\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/checker.py\", line 5412, in visit_decorator\n self.visit_decorator_inner(e)\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/checker.py\", line 5419, in visit_decorator_inner\n self.check_func_item(e.func, name=e.func.name, allow_empty=allow_empty)\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/checker.py\", line 1231, in check_func_item\n self.check_func_def(defn, typ, name, allow_empty)\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/checker.py\", line 1504, in check_func_def\n self.accept(item.body)\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/checker.py\", line 635, in accept\n stmt.accept(self)\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/nodes.py\", line 1542, in accept\n return visitor.visit_block(self)\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/checker.py\", line 3126, in visit_block\n self.accept(s)\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/checker.py\", line 635, in accept\n stmt.accept(self)\n ~~~~~~~~~~~^^^^^^\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/nodes.py\", line 1629, in accept\n return visitor.visit_assignment_stmt(self)\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/checker.py\", line 3177, in visit_assignment_stmt\n self.check_assignment(s.lvalues[-1], s.rvalue, s.type is None, s.new_syntax)\n ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/checker.py\", line 3233, in check_assignment\n self.check_assignment_to_multiple_lvalues(\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^\n lvalue.items, rvalue, rvalue, infer_lvalue_type\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n )\n ^\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/checker.py\", line 3984, in check_assignment_to_multiple_lvalues\n self.check_multi_assignment(lvalues, rvalue, context, infer_lvalue_type)\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/checker.py\", line 4062, in check_multi_assignment\n self.check_multi_assignment_from_tuple(\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^\n lvalues, rvalue, rvalue_type, context, undefined_rvalue, infer_lvalue_type\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n )\n ^\n File \"/Users/gooverdian/Projects/xhh/.venv/lib/python3.13/site-packages/mypy/checker.py\", line 4202, in check_multi_assignment_from_tuple\n assert isinstance(reinferred_rvalue_type, TupleType)\n ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nAssertionError: \n```\n\n**To Reproduce**\n\nThis file is not new, so the diff, which lead to that error is adding types to some members of a left tuple before the assignment:\n```diff\n+ tab_content: PriceCombinedDBAccessTabContentDto\n+ price_region_stats: PriceRegionStats\n\n(\n price_data,\n tab_content,\n all_price_regions,\n all_prof_role_groups,\n price_region_stats,\n has_civ_service,\n) = await asyncio.gather(\n get_price_data(handler, TabName.COMBINED_DBACCESS, price_description, backoffice_employer_id, session),\n get_price_tab_content(http_client, config, TabName.COMBINED_DBACCESS, backoffice_employer_id),\n get_all_price_regions(handler),\n get_all_prof_role_groups(handler),\n get_price_regions_stats(http_client, config),\n check_employer_has_service_no_handler(\n http_client, config, employer_id_or_backoffice_employer_id, ProductItemCode.ContactsView\n ),\n)\n```\n\nUPD: Found a way to reproduce it in playground https://mypy-play.net/?mypy=latest&python=3.13&gist=ca818b7f434ca646dd6373b26f5b58f6, seems like there would be an error if it wouldn't crash.\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: 1.15.0, 1.18.2, git master\n- Mypy command-line flags: --config-file (path to config), --show-traceback, (path to file)\n- Mypy configuration options from `mypy.ini` (and other config files):\n ```\n [tool.mypy]\n warn_redundant_casts = true\n warn_unused_ignores = true\n warn_unused_configs = true\n show_error_codes = true\n ignore_missing_imports = true\n follow_imports = \"silent\"\n follow_untyped_imports = true\n disallow_untyped_calls = false\n disallow_incomplete_defs = true\n disallow_untyped_decorators = true\n check_untyped_defs = true\n strict = true\n disallow_untyped_defs = true\n disallow_any_generics = true\n disallow_subclassing_any = true\n warn_return_any = true\n enable_error_code = [\n \"deprecated\",\n \"ignore-without-code\",\n ]\n python_version = \"3.13\"\n exclude = [\n \"xhh/pages/employer/documents-management\",\n \"xhh/pages/employer/financial-documents\",\n \"xhh/pages/employer/reviews-settings\",\n \"xhh/page.py\",\n ]\n ```\n- Python version used: 3.13\n- Operating system and version: mac sequoia 15.6.1, alpine ubuntu (docker)\n\n\u003c!--\nYou can freely edit this text, please remove all the lines\nyou believe are unnecessary.\n-->\n","author":{"url":"https://github.com/gooverdian","@type":"Person","name":"gooverdian"},"datePublished":"2025-09-24T10:08:49Z","url":"https://github.com/python/mypy/issues/19920"}
| 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:0c4b0766-459b-52c9-ea03-bfeb738a9db8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D79A:3DAD59:1792B98:1F15922:6B001C72 |
| html-safe-nonce | a0c6be586ae666a06c6469298ba179709673be0cd38d00afe1e4416d6c7333af |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzlBOjNEQUQ1OToxNzkyQjk4OjFGMTU5MjI6NkIwMDFDNzIiLCJ2aXNpdG9yX2lkIjoiMzU4OTM1NTE0ODAyOTIwNTYxOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2494043e1dacfea3d6ec589f7d567300294f5f8452d4b7f98c1b1b959df7d0c5 |
| hovercard-subject-tag | issue:3448691113 |
| 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/19920/issue_layout |
| twitter:image | https://opengraph.githubassets.com/08bed1d30fa8d4736301848812440b7ea10e7a01843a899cce439bf0d159c8a9/python/mypy/issues/19920 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/08bed1d30fa8d4736301848812440b7ea10e7a01843a899cce439bf0d159c8a9/python/mypy/issues/19920 |
| og:image:alt | Crash Report We got a tuple to tuple assignment with asyncio.gather, which crashes mypy, it looks like this: tab_content: PriceCombinedDBAccessTabContentDto price_region_stats: PriceRegionStats ( #... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gooverdian |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width