--warn-redundant-cast doesn’t warn for simple generic types
まだ誰も着手していません。
評価
調査の方向性
リンクされた mypy-play の再現コードから始め、--warn-redundant-casts を付けて実行し、cast(list[int], identity(xs)) に対する警告が欠落していることを確認します。ジェネリックなリスト型に対する冗長な cast のチェックを追跡し、この cast が報告される一方で、既存の type reveal が有効なままであることを示す回帰テストを追加します。
索引モデルが issue の本文から書いたものです。
説明
Bug Report
See reproducer
To Reproduce
from typing import TypeVar, cast
T = TypeVar("T")
def identity(xs: list[T]) -> list[T]:
return xs
def f(xs: list[int]) -> list[int]:
reveal_type(identity(xs))
return cast(list[int], identity(xs)) # --warn-redundant-casts should trigger here
Expected Behavior
warns that the cast is redundant
Actual Behavior
doesn’t warn
Your Environment
- Mypy version used: 2.3.0
- Mypy command-line flags:
--warn-redundant-casts - Mypy configuration options from
mypy.ini(and other config files):warn-redundant-casts = true - Python version used: any
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- 平均マージ
- 1日 12時間
- マージ済み PR(30日)
- 58
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python/mypy のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
bug topic-configuration topic-error-reporting
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
bug topic-attrs
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
anthropics/skills#1811 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
speaches-ai/speaches#678 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
datalayer/mcp-compose#42 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
conda-forge/spacy-feedstock#177 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
UKGovernmentBEIS/inspect_evals#2523 ·