Support warning on unused ignores without treating them as an error
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
Feature
Mypy's --warn-unused-ignores option currently treats unused ignores as an error, rather than merely warning about them but still exiting zero.
Mypy should support an option where unused ignores are still warned about in the output, but are not treated as an error.
Current behavior:
❯ cat test.py
x = 1 + 1 # type: ignore
❯ mypy test.py
Success: no issues found in 1 source file
❯ mypy --strict test.py # exits nonzero
test.py:1: error: Unused "type: ignore" comment
Found 1 error in 1 file (checked 1 source file)
❯ mypy --strict --no-warn-unused-ignores test.py # exits zero
Success: no issues found in 1 source file
The current warn-unused-ignores behavior, where you have to choose between either erroring or total silence when there's an unused ignore (and can't actually just get a warning), could even be considered a bug.
Pitch
To preserve backward compatibility, perhaps something like this would work:
❯ mypy --unused-ignores=warning # emit a warning but don't exit nonzero
❯ mypy --unused-ignores=error # emit an error and exit nonzero, same as --warn-unused-ignores now
❯ mypy --warn-unused-ignores # same as --unused-ignores=error
❯ mypy --unused-ignores=none # no output, exit zero, same as --no-warn-unused-ignores now
❯ mypy --no-warn-unused-ignores # same as --unused-ignores=none
And the mypy -h usage output would just steer people toward using the new, less confusing options. Potentially using the old options could emit a message like "This option is deprecated, please use <new option> instead", if we may want to remove the confusing options at some point in the future.
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 dalla gestione della riga di comando illustrata dagli esempi di --warn-unused-ignores e traccia il modo in cui le diagnostiche relative alle ignorazioni inutilizzate influiscono sullo stato di uscita. Definisci le modalità avviso, errore e disabilitata mantenendo i flag esistenti, quindi aggiungi la copertura per ogni comportamento della riga di comando e verifica gli output e i codici di uscita documentati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- cli, 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