emit a warning for "unused Any"
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
A common problem afflicting novices getting into python static type annotations is that they assume Any is the top type in Python, like how Never is its bottom type. Hence, they use Any too much, where it is not necessary.
I think we should emit a warning when an explicit Any annotation is used but didn't have to be, much like what we do for warn-redundant-casts.
In fact, I think there are three related warnings we should emit:
- If Any is used but object would have worked
- If Any is used but mypy was able to deduce a type that worked (using the regular mypy deduction)
- If there is a Callable special form with ... (Ellipsis) in place of the list of parameter types (basically just another way to spell Any, see https://typing.python.org/en/latest/spec/callables.html#meaning-of-in-callable) but one of the previous two cases holds
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 esaminando il comportamento esistente di mypy per warn-redundant-casts e la semantica dei puntini di sospensione di Callable nella specifica di typing. Il lavoro è completo quando mypy è in grado di distinguere i tre casi proposti: Any non necessario quando object è sufficiente, Any quando l’inferenza fornisce un tipo utilizzabile e la forma Callable corrispondente, con avvisi per ogni caso applicabile.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- compilers, tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100