Regression in 2.4.0: empty constraint tuple in PEP 695 type parameter (`class C[T: ()]`) is no longer reported
メンテナーはふだん 1 日以内に返信
@CheerathAniketh がすでに取り組んでいます。
2026年10月11日 から。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 72/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
- 領域
- backend, testing-qa
調査の方向性
60行目にある適合性テスト generics_syntax_declarations.py から始めます。このテストはすでに class ClassK[T: ()] に対するエラーを期待しています。mypy 2.3.0 と 2.4.0 で結果を比較し、PEP 695 型パラメーターの空の制約の処理を追ってください。2.4.0 でテストが期待される “at least two constrained types” エラーを報告すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Bug Report
mypy 2.4.0 no longer reports an error for a PEP 695 type parameter whose constraint tuple is empty (class C[T: ()]). mypy 2.1.0, 2.2.0 and 2.3.0 all report Type variable must have at least two constrained types [misc] on that line. The one-element case T: (str,) and the legacy TypeVar("T", str) are still reported in 2.4.0, so only the empty-tuple path regressed.
To Reproduce
class ClassK[T: ()]: # expected: error: Type variable must have at least two constrained types [misc]
...
class ClassL[T: (str,)]: # still reported in 2.4.0
...
$ mypy --python-version 3.12 repro.py
Expected Behavior
An error on the ClassK line, as in mypy ≤ 2.3.0. CPython itself rejects the declaration at runtime (TypeError: A single constraint is not allowed / empty constraints), and pyright 1.1.414, pyrefly 1.3.2, ty 0.0.86 and zuban 0.10.0 all report it.
Actual Behavior
mypy 2.4.0:
repro.py:4: error: Type variable must have at least two constrained types [misc]
Found 1 error in 1 file (checked 1 source file)
(only ClassL; ClassK on line 1 is silently accepted)
mypy 2.3.0:
repro.py:1: error: Type variable must have at least two constrained types [misc]
repro.py:4: error: Type variable must have at least two constrained types [misc]
Found 2 errors in 1 file (checked 1 source file)
This also flips the typing conformance test generics_syntax_declarations.py (line 60, class ClassK[T: ()]: # E) from automated Pass (mypy 2.1.0, as in the published results) to Fail with 2.4.0.
Your Environment
- Mypy version used: 2.4.0 (compiled: yes); compared against 2.1.0 / 2.2.0 / 2.3.0 in separate venvs
- Mypy command-line flags:
--python-version 3.12(also reproduces with no flags) - Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.12.15, macOS arm64
- 主要言語
- Python
- スター
- 20.7k
- フォーク
- 3.3k
- 平均マージ
- 1日 20時間
- マージ済み PR(30日)
- 106
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python/mypy のほかの issue
-
T-string below Python 3.14 also reports import-not-found for string.templatelib on line 1対応中かも @jw9829 が 1 日前に担当しました。 オープンbug topic-parser
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
python/mypy#22184 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
`stubgen --inspect-mode` crashes with `AttributeError on PEP 604 union syntax (X | Y)` *(mypy 2.1.0)*対応中かも @ayushdoesdev が 70 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
Inconsistent description of `strict_optional`対応中かも @Joosboy が 87 日前に担当しました。 オープンdocumentation
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
python/mypy#21658 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Cannot set `output` in `mypy.ini`再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンbug topic-configuration topic-error-reporting
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
python/mypy#21376 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
[Bug]: LangGraph Store sync put bypasses namespace validation対応中かも @ktz03 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
volcengine/OpenViking#6050 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: Streamed /v1/chat/completions sends unredacted agent error text (keys) in the final chunk対応中かも @rodricksz4h5 が今日担当しました。 オープンarea/streaming comp/gateway P2 type/security
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
NousResearch/hermes-agent#138245 ·
メンテナーはふだん 1 日以内に返信
-
[oblt-aw][autodoc] Update user onboarding guide for mandatory trigger CODEOWNERS step対応中かも @github-actions が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 1 日以内に返信
-
correction metadata
難易度 2/5 1時間未満 初心者へのやさしさ 68/100
acl-org/acl-anthology#10378 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
cloudtrail_multi_region_enabled_logging_management_events fails when the advanced event selector has a custom name対応中かも @12YYCCYY16 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
prowler-cloud/prowler#13033 ·
メンテナーはふだん 1 日以内に返信