Skip to content

Assertion failure crash: assert not self.has_type_var_tuple_type #20527

@correctmost

Description

@correctmost

Crash Report

The snippet below crashes mypy 1.19.1 and master (c41dbd0). The crash seems similar to #20287.

Traceback

Traceback (most recent call last):
  File ".venv-mypy/bin/mypy", line 7, in <module>
    sys.exit(console_entry())
  File "mypy/mypy/__main__.py", line 15, in console_entry
    main()
  File "mypy/mypy/main.py", line 135, in main
    res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
  File "mypy/mypy/main.py", line 219, in run_build
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
  File "mypy/mypy/build.py", line 320, in build
    result = build_inner(
  File "mypy/mypy/build.py", line 417, in build_inner
    graph = dispatch(sources, manager, stdout)
  File "mypy/mypy/build.py", line 3178, in dispatch
    process_graph(graph, manager)
  File "mypy/mypy/build.py", line 3588, in process_graph
    done, still_working, results = manager.wait_for_done(graph)
  File "mypy/mypy/build.py", line 1070, in wait_for_done
    process_stale_scc(graph, next_scc, self)
  File "mypy/mypy/build.py", line 3745, in process_stale_scc
    mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)
  File "mypy/mypy/semanal_main.py", line 94, in semantic_analysis_for_scc
    process_top_levels(graph, scc, patches)
  File "mypy/mypy/semanal_main.py", line 232, in process_top_levels
    deferred, incomplete, progress = semantic_analyze_target(
  File "mypy/mypy/semanal_main.py", line 409, in semantic_analyze_target
    analyzer.refresh_partial(
  File "mypy/mypy/semanal.py", line 703, in refresh_partial
    self.refresh_top_level(node)
  File "mypy/mypy/semanal.py", line 721, in refresh_top_level
    self.accept(d)
  File "mypy/mypy/semanal.py", line 7598, in accept
    node.accept(self)
    ~~~~~~~~~~~^^^^^^
  File "mypy/mypy/nodes.py", line 1487, in accept
    return visitor.visit_class_def(self)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
  File "mypy/mypy/semanal.py", line 1829, in visit_class_def
    self.analyze_class(defn)
    ~~~~~~~~~~~~~~~~~~^^^^^^
  File "mypy/mypy/semanal.py", line 2023, in analyze_class
    self.setup_type_vars(defn, tvar_defs)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "mypy/mypy/semanal.py", line 2065, in setup_type_vars
    defn.info.add_type_vars()
    ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "mypy/mypy/nodes.py", line 3620, in add_type_vars
    assert not self.has_type_var_tuple_type
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: 

To Reproduce

class C[*T, *U](T, U):
    pass

Your Environment

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

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