Crash on unpacked tuple in tuple type definition
还没有人认领这个 Issue。
评估
调研方向
先从提供的复现用例和命令开始,然后跟踪报告的路径,依次查看 mypy/checkexpr.py、mypy/applytype.py、mypy/subtypes.py、mypy/types.py 和 mypy/typeops.py。确认 deque[Outer] 中的嵌套元组别名不再引发 INTERNAL ERROR 或 traceback,并在项目中针对该类型检查路径的现有测试所在位置添加或更新回归测试覆盖。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- Python
- 星标
- 20.6k
- 派生
- 3.3k
- 平均合并
- 1 天 12 小时
- 30 天内合并 PR
- 58
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python/mypy 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
-
documentation
难度 2/5 1-3 小时 新手友好度 72/100
-
bug topic-configuration topic-error-reporting
难度 2/5 1-3 小时 新手友好度 68/100
-
bug topic-attrs
难度 2/5 1-3 小时 新手友好度 62/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
anthropics/skills#1811 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
speaches-ai/speaches#678 ·
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
datalayer/mcp-compose#42 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
conda-forge/spacy-feedstock#177 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
UKGovernmentBEIS/inspect_evals#2523 ·