GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — IndexError when unpacking type · Issue #20913 · python/mypy

IndexError when unpacking type #20913

New issue
Copy link
New issue
Copy link
Closed
#21551
Closed
IndexError when unpacking type#20913
#21551
Copy link
Labels
crashtopic-pep-646PEP 646 (TypeVarTuple, Unpack)topic-pep-695Issues related to PEP 695 syntax

Description

@correctmost
correctmost
opened on Feb 27, 2026
Issue body actions

Crash Report

The snippet below crashes mypy 1.19.1 and master (f363f35).

Traceback

Traceback (most recent call last):
  File ".venv-mypy/bin/mypy", line 6, in <module>
    sys.exit(console_entry())
  File "mypy/mypy/__main__.py", line 15, in console_entry
    main()
  File "mypy/mypy/main.py", line 130, in main
    res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
  File "mypy/mypy/main.py", line 214, in run_build
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
  File "mypy/mypy/build.py", line 378, in build
    result = build_inner(
  File "mypy/mypy/build.py", line 478, in build_inner
    graph = dispatch(sources, manager, stdout)
  File "mypy/mypy/build.py", line 3652, in dispatch
    process_graph(graph, manager)
  File "mypy/mypy/build.py", line 4105, in process_graph
    done, still_working, results = manager.wait_for_done(graph)
  File "mypy/mypy/build.py", line 1173, in wait_for_done
    process_stale_scc(graph, next_scc, self)
  File "mypy/mypy/build.py", line 4268, in process_stale_scc
    mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)
  File "mypy/mypy/semanal_main.py", line 92, in semantic_analysis_for_scc
    process_top_levels(graph, scc, patches)
  File "mypy/mypy/semanal_main.py", line 230, in process_top_levels
    deferred, incomplete, progress = semantic_analyze_target(
  File "mypy/mypy/semanal_main.py", line 407, in semantic_analyze_target
    analyzer.refresh_partial(
  File "mypy/mypy/semanal.py", line 701, in refresh_partial
    self.refresh_top_level(node)
  File "mypy/mypy/semanal.py", line 719, in refresh_top_level
    self.accept(d)
  File "mypy/mypy/semanal.py", line 7627, in accept
    node.accept(self)
    ~~~~~~~~~~~^^^^^^
  File "mypy/mypy/nodes.py", line 1752, in accept
    return visitor.visit_assignment_stmt(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "mypy/mypy/semanal.py", line 3345, in visit_assignment_stmt
    self.process_type_annotation(s)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
  File "mypy/mypy/semanal.py", line 3883, in process_type_annotation
    if analyzed is None or has_placeholder(analyzed):
                           ~~~~~~~~~~~~~~~^^^^^^^^^^
  File "mypy/mypy/semanal_shared.py", line 377, in has_placeholder
    return typ.accept(HasPlaceholders())
           ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "mypy/mypy/types.py", line 418, in accept
    return visitor.visit_type_alias_type(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "mypy/mypy/type_visitor.py", line 598, in visit_type_alias_type
    return get_proper_type(t).accept(self)
           ~~~~~~~~~~~~~~~^^^
  File "mypy/mypy/types.py", line 3648, in get_proper_type
    typ = typ._expand_once()
  File "mypy/mypy/types.py", line 382, in _expand_once
    return self.alias.target.accept(InstantiateAliasVisitor(mapping))
           ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "mypy/mypy/types.py", line 1672, in accept
    return visitor.visit_instance(self)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "mypy/mypy/expandtype.py", line 215, in visit_instance
    args = self.expand_type_tuple_with_unpack(t.args)
  File "mypy/mypy/expandtype.py", line 533, in expand_type_tuple_with_unpack
    items.append(item.accept(self))
                 ~~~~~~~~~~~^^^^^^
  File "mypy/mypy/types.py", line 1236, in accept
    return visitor.visit_unpack_type(self)
           ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "mypy/mypy/expandtype.py", line 387, in visit_unpack_type
    return UnpackType(t.type.accept(self))
                      ~~~~~~~~~~~~~^^^^^^
  File "mypy/mypy/types.py", line 1672, in accept
    return visitor.visit_instance(self)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "mypy/mypy/expandtype.py", line 228, in visit_instance
    arg = args[0]
          ~~~~^^^
IndexError: list index out of range

To Reproduce

from typing import Unpack

class C[*Ts]:
    pass

type T[T, *Ts] = C[*Ts]

x: T[bool, Unpack[tuple[()]]]

Your Environment

  • Mypy version used: 1.19.1 and f363f35
  • Mypy command-line flags: N/A
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.14.3
  • Operating system and version: Arch Linux

Activity

  1. correctmost
    added
    crash
    on Feb 27, 2026
  2. A5rocks
    added
    topic-pep-695Issues related to PEP 695 syntax
    on Feb 27, 2026
  3. ilevkivskyi
    added
    topic-pep-646PEP 646 (TypeVarTuple, Unpack)
    on Feb 27, 2026
  4. bxff
    added 7 commits that reference this issue on Feb 28, 2026

    Fix IndexError when unpacking empty tuple in type alias

    This issue will close once commit 0846c5f is merged into the 'master' branch.
    0846c5f

    Fix IndexError when unpacking empty tuple in type alias

    This issue will close once commit 5f2afae is merged into the 'master' branch.
    5f2afae

    Fix IndexError when unpacking empty tuple in type alias

    This issue will close once commit debf2a5 is merged into the 'master' branch.
    debf2a5

    Fix IndexError when unpacking empty tuple in type alias

    This issue will close once commit 14b3493 is merged into the 'master' branch.
    14b3493

    Fix IndexError when unpacking empty tuple in type alias

    This issue will close once commit 8d4dd34 is merged into the 'master' branch.
    8d4dd34

    Fix IndexError when unpacking empty tuple in type alias

    This issue will close once commit ab2bdd7 is merged into the 'master' branch.
    ab2bdd7

    Fix IndexError when unpacking empty tuple in type alias

    This issue will close once commit 4c1229e is merged into the 'master' branch.
    4c1229e
  5. ilevkivskyi
    added a commit that references this issue on May 28, 2026

    Fix crash in new-style type alias with variadic unpack (#21551)

    8f4c840
  6. ilevkivskyi
    closed this as completedin #21551on May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashtopic-pep-646PEP 646 (TypeVarTuple, Unpack)topic-pep-695Issues related to PEP 695 syntax

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.