1.16 regression: `--warn-unused-ignore` now complains in ignored-but-correct places
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
this appears to have changed behaviour in mypy 1.15 -- I personally prefer the behaviour in 1.15 but would understand if it needed to change. I don't see it mentioned in the changelog however
Bug Report
we're working on incrementally typing a large codebase -- often this means fixing a particular callsite or file at a time (sometimes by intentionally ignoring errors unfortunately)
it seems that in a module with a particular error code (temporarily) disabled, --warn-unused-ignores will complain about a "correct" type ignore (I say "correct" here as it will complain when the file is no longer blocklisted) -- will provide a small example below
To Reproduce
# t.py
def f() -> None:
x: int = 'hi' # type: ignore[assignment]
[mypy]
warn_unused_ignores = true
[mypy-t]
disable_error_code = assignment
Expected Behavior
$ mypy --version
mypy 1.15.0 (compiled: yes)
$ mypy t.py
Success: no issues found in 1 source file
Actual Behavior
$ mypy --version
mypy 1.16.0 (compiled: yes)
$ mypy t.py
t.py:2: error: Unused "type: ignore" comment [unused-ignore]
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.16.0 (regression from 1.15.0)
- Mypy command-line flags: (see above)
- Mypy configuration options from
mypy.ini(and other config files): (see above) - Python version used: 3.13.1
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
Beginnen Sie damit, das Problem mit der gezeigten t.py-Datei und der mypy-Konfiguration zu reproduzieren, und vergleichen Sie das Verhalten von 1.15.0 und 1.16.0. Suchen Sie anschließend die Implementierung oder Tests für warn_unused_ignores und per-module disable_error_code. Die Aufgabe ist erledigt, wenn die ignorierte Zuweisung nicht als ungenutzt gemeldet wird, sobald dieser Fehlercode deaktiviert ist, und eine Regressionstestabdeckung vorhanden ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 45/100