Assertion failure crash: assert not any(isinstance(t, Parameters) for t in arg_types)
Offen
Dieses Issue hat noch niemand übernommen.
crash
topic-paramspec
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Crash Report
mypy 1.20.2 and master (0ea16df0c) crash on the snippet below.
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 16, in console_entry
main()
File "mypy/mypy/main.py", line 154, in main
res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
File "mypy/mypy/main.py", line 244, in run_build
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
File "mypy/mypy/build.py", line 422, in build
result = build_inner(
File "mypy/mypy/build.py", line 537, in build_inner
graph = dispatch(sources, manager, stdout, connect_threads)
File "mypy/mypy/build.py", line 4150, in dispatch
process_graph(graph, manager)
File "mypy/mypy/build.py", line 4618, in process_graph
done, still_working, results = manager.wait_for_done(graph)
File "mypy/mypy/build.py", line 1492, in wait_for_done
process_stale_scc(graph, next_scc, self)
File "mypy/mypy/build.py", line 4785, in process_stale_scc
mypy.semanal_main.semantic_analysis_for_scc(graph, scc, manager.errors)
File "mypy/mypy/semanal_main.py", line 91, in semantic_analysis_for_scc
process_top_levels(graph, scc, patches)
File "mypy/mypy/semanal_main.py", line 200, in process_top_levels
deferred, incomplete, progress = semantic_analyze_target(
File "mypy/mypy/semanal_main.py", line 380, 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 728, in refresh_top_level
self.accept(d)
File "mypy/mypy/semanal.py", line 7701, in accept
node.accept(self)
~~~~~~~~~~~^^^^^^
File "mypy/mypy/nodes.py", line 1903, in accept
return visitor.visit_assignment_stmt(self)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "mypy/mypy/semanal.py", line 3366, in visit_assignment_stmt
self.process_type_annotation(s)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
File "mypy/mypy/semanal.py", line 3901, in process_type_annotation
analyzed = self.anal_type(s.type, allow_tuple_literal=allow_tuple_literal)
File "mypy/mypy/semanal.py", line 7858, in anal_type
typ = typ.accept(a)
File "mypy/mypy/types.py", line 1094, in accept
return visitor.visit_unbound_type(self)
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "mypy/mypy/typeanal.py", line 281, in visit_unbound_type
typ = self.visit_unbound_type_nonoptional(t, defining_literal)
File "mypy/mypy/typeanal.py", line 461, in visit_unbound_type_nonoptional
special = self.try_analyze_special_unbound_type(t, fullname)
File "mypy/mypy/typeanal.py", line 655, in try_analyze_special_unbound_type
return self.analyze_callable_type(t)
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
File "mypy/mypy/typeanal.py", line 1588, in analyze_callable_type
) or self.analyze_callable_args_for_concatenate(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
callable_args, ret_type, fallback
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "mypy/mypy/typeanal.py", line 1509, in analyze_callable_args_for_concatenate
tvar_def = self.anal_type(callable_args, allow_param_spec=True)
File "mypy/mypy/typeanal.py", line 1923, in anal_type
analyzed = t.accept(self)
File "mypy/mypy/types.py", line 1094, in accept
return visitor.visit_unbound_type(self)
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "mypy/mypy/typeanal.py", line 281, in visit_unbound_type
typ = self.visit_unbound_type_nonoptional(t, defining_literal)
File "mypy/mypy/typeanal.py", line 514, in visit_unbound_type_nonoptional
return self.apply_concatenate_operator(t)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
File "mypy/mypy/typeanal.py", line 588, in apply_concatenate_operator
pre = Parameters(
args + pre.arg_types,
...<3 lines>...
column=t.column,
)
File "mypy/mypy/types.py", line 1946, in __init__
assert not any(isinstance(t, Parameters) for t in arg_types)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
To Reproduce
from typing import Callable, Concatenate
f: Callable[Concatenate[Concatenate[...], ...], ...]
Your Environment
- Mypy version used: 1.20.2 and 0ea16df0c
- Mypy command-line flags: N/A
- Mypy configuration options from
mypy.ini(and other config files): N/A - Python version used: 3.14.4
- Operating system and version: Arch Linux
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Reproduziere den Absturz mit dem bereitgestellten Callable- und Concatenate-Snippet und untersuche anschließend mypy/typeanal.py im Bereich von apply_concatenate_operator sowie types.py im Bereich von Parameters.init. Verfolge, wie das verschachtelte Concatenate die Assertion erreicht; abgeschlossen ist die Aufgabe, wenn der Reproducer nicht mehr abstürzt und das Verhalten durch einen Regressionstest abgedeckt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 72/100