Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Crash on unpacked tuple in tuple type definition

未关闭
#21,933 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
python
领域
compilers

调研方向

先从提供的复现用例和命令开始,然后跟踪报告的路径,依次查看 mypy/checkexpr.py、mypy/applytype.py、mypy/subtypes.py、mypy/types.py 和 mypy/typeops.py。确认 deque[Outer] 中的嵌套元组别名不再引发 INTERNAL ERROR 或 traceback,并在项目中针对该类型检查路径的现有测试所在位置添加或更新回归测试覆盖。

由索引模型根据 Issue 内容生成。

描述

crash topic-pep-646

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

python/mypy 的其他 Issue

查看 python/mypy 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。