mypy cannot decide if a cast is necessary or redundant
オープン
まだ誰も着手していません。
bug
topic-inference
topic-literal-types
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Bug Report
Here a case where mypy says a cast is redundant, but if you remove the cast, mypy cannot infer the right type.
To Reproduce
Expected Behavior
Either no error with the cast or no error without the cast.
Actual Behavior
Using a type cast, mypy says it's not needed.
Without the type cast, mypy cannot infer the type.
Your Environment
- Mypy version used: 2.10
- Mypy configuration options from
mypy.ini(and other config files): warn_redundant_casts = true - Python version used: 3.14
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされている Gist と、warn_redundant_casts を有効にした mypy-playground の再現例から始め、次に mypy が cast をどのように検査し、それなしで式をどのように推論するかを追跡します。報告されている Python と mypy のバージョンで動作を確認します。cast がある場合もない場合も、例でエラーが発生しなければ完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 58/100