#21907·mypy

"INTERNAL_ERROR": 使用带有受限返回类型的可调用参数的通用函数,后跟类型为 `*Tuple[int, float]` 的 `*args` 会导致 mypy 发生崩溃

作者: willy-b创建于 2026年8月28日更新于 2026年9月15日
标签crash

崩溃报告

  • 创建 crash_example.py 如下所示:
from typing import *

# mypy latest from master branch crashes (mypy 2.4.0+dev.b974556f84bd4ff5280b66bce1413fa942d1261e) (and earlier prod releases as well)
def generic_fun[
  TypeVarWithConstraints: (str, bytes),
](
  a: Callable[..., TypeVarWithConstraints],
  *args: *Tuple[int, float]
): pass
  • 在 GitHub (2.4.0+dev) 上运行 mypy 2.3.1 或最新的 master,并观察出现"INTERNAL_ERROR"的崩溃:
[liveuser@localhost-live ~]$ mypy crash_example.py --show-traceback
crash_example.py:4: 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: 2.4.0+dev.b974556f84bd4ff5280b66bce1413fa942d1261e
[--show-traceback output is included further down]