Crash on unpacked tuple in tuple type definition
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Crash Report
Mypy 1.20.2 is crashing when processing type definition of a tuple that unpacks another tuple. I have a reproducer on mypy-play with latest version (2.3.1). See https://mypy-play.net/?gist=43e256f314819d34c14f92b9098ed40c
Traceback
mre.py:12: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 1.20.2
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "mypy/checkexpr.py", line 6092, in accept
File "mypy/checkexpr.py", line 6127, in accept_maybe_cache
File "mypy/nodes.py", line 2469, in accept
File "mypy/checkexpr.py", line 502, in visit_call_expr
File "mypy/checkexpr.py", line 639, in visit_call_expr_inner
File "mypy/checkexpr.py", line 1489, in check_call_expr_with_callee_type
File "mypy/checkexpr.py", line 1593, in check_call
File "mypy/checkexpr.py", line 2749, in check_overload_call
File "mypy/checkexpr.py", line 2917, in infer_overload_return_type
File "mypy/checkexpr.py", line 1582, in check_call
File "mypy/checkexpr.py", line 1747, in check_callable_call
File "mypy/checkexpr.py", line 2060, in infer_function_type_arguments_using_context
File "mypy/checkexpr.py", line 3292, in apply_generic_arguments
File "mypy/applytype.py", line 115, in apply_generic_arguments
File "mypy/applytype.py", line 79, in get_target_type
File "mypy/subtypes.py", line 189, in is_subtype
File "mypy/subtypes.py", line 363, in _is_subtype
File "mypy/types.py", line 2818, in accept
File "mypy/subtypes.py", line 798, in visit_tuple_type
File "mypy/typeops.py", line 119, in tuple_fallback
NotImplementedError:
mre.py:12: note: use --pdb to drop into pdb
To Reproduce
See https://mypy-play.net/?gist=43e256f314819d34c14f92b9098ed40c
"""
Minimal reproducer: mypy 1.20.2 (and latest 2.3.1) crashes on a nested tuple type alias unpack.
"""
from collections import deque
type Inner = tuple[int, str]
type Outer = tuple[bool, *Inner]
class K(Base):
q: deque[Outer] = deque()
class Base: ...
Your Environment
- Mypy version used: 1.20.2 and 2.3.1
- Mypy command-line flags:
python -m mypy --python-version 3.12 --no-incremental --cache-dir=/dev/null --show-traceback mre.py - Python version used: Python 3.12.13
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
Beginne mit dem bereitgestellten Reproducer und Befehl und verfolge dann den gemeldeten Pfad durch mypy/checkexpr.py, mypy/applytype.py, mypy/subtypes.py, mypy/types.py und mypy/typeops.py. Bestätige, dass der verschachtelte Tupel-Alias in deque[Outer] keinen INTERNAL ERROR oder Traceback mehr auslöst, und füge eine Regressionstestabdeckung hinzu bzw. aktualisiere sie dort, wo die bestehenden Tests des Projekts für diesen Typprüfpfad hingehören.
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
- Aktiv
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 68/100