More specific inline dict type inference can fail on 1.17.0
オープン
まだ誰も着手していません。
bug
topic-inference
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Bug Report
More specific inline dict type inference can fail on 1.17.0.
To Reproduce
The following fails on 1.17.0 but is fine on 1.16.1 (the playground link uses master as 1.17.0 isn't available there):
https://mypy-play.net/?mypy=master&python=3.13&gist=7e77b89fe5f9cb7e548c4ef83b3783c1
Revealing the type for the inline dict gives:
- 1.16.1:
builtins.dict[builtins.str, Union[typing.Collection[builtins.str], None]] - 1.17.0:
builtins.dict[builtins.str, builtins.dict[builtins.str, builtins.list[Any] | None] | builtins.dict[builtins.str, builtins.str] | builtins.str | None]
Expected Behavior
No mypy errors.
Actual Behavior
main.py:11: error: Dict entry 0 has incompatible type "str": "None"; expected "str": "str" [dict-item]
main.py:12: error: Dict entry 1 has incompatible type "str": "list[Never]"; expected "str": "str" [dict-item]
Found 2 errors in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.17.0
- Mypy command-line flags: N/A
- Mypy configuration options from
mypy.ini(and other config files): N/A - Python version used: 3.13.5
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされた mypy playground の再現例から始め、1.16.1、1.17.0、master での動作を比較してください。issue ではリポジトリ内のファイルやテストが指定されていないため、再現されたエラーを手がかりに inline dictionary の型推論パスを追跡してください。完了の条件は、期待される推論型を維持したまま、例でエラーが発生しないことです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100