python / python/mypy

Assertion failure crash: assert not self.has_type_var_tuple_type

Offen
#20,527 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

crash topic-pep-646 topic-pep-695
Vorherrschende Sprache
Python
Sterne
20.6k
Forks
3.3k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Reproduziere den Absturz mit der bereitgestellten Klassendefinition unter Verwendung von mypy 1.19.1 oder master. Beginne in mypy/nodes.py bei add_type_vars und verfolge die Aufrufer durch setup_type_vars in mypy/semanal.py. Erledigt ist die Aufgabe, wenn die Assertion mypy für diese Eingabe nicht mehr zum Absturz bringt und eine Regressionstestabdeckung den Fix schützt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
devtools
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
55/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.