--warn-redundant-cast doesn’t warn for simple generic types
Aperta
Nessuno ha ancora preso questa issue.
bug
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con il riproduttore mypy-play collegato ed eseguilo con --warn-redundant-casts per confermare la mancanza dell'avviso per cast(list[int], identity(xs)). Traccia il controllo dei cast ridondanti per i tipi lista generici, quindi aggiungi un test di regressione che mostri che questo cast viene segnalato, mentre il type reveal esistente rimane valido.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 52/100