Support warning on unused ignores without treating them as an error
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der in den Beispielen für --warn-unused-ignores dargestellten Verarbeitung der Befehlszeile und verfolge, wie sich Diagnosen zu ungenutzten Ignorierungen auf den Exit-Status auswirken. Definiere die Modi „Warnung“, „Fehler“ und „Deaktiviert“, wobei die vorhandenen Flags erhalten bleiben, füge anschließend Abdeckung für jedes Verhalten der Befehlszeile hinzu und überprüfe die dokumentierten Ausgaben und Exit-Codes.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- cli, tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100