python / python/mypy

Daemonized mypy ignores errors on files that previously passed (cache bug)

Offen
#18,131 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug topic-daemon
Vorherrschende Sprache
Python
Sterne
20.6k
Forks
3.3k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

Bug Report
dmypy is failing to notice type errors when they are introduced into a file that has already passed type checking. I'm observing this even on extremely minimal examples. It seems like once a file passes checks once it is never checked again by dmypy.

Specifically, this seems to happen when dmypy is given a package. Explicitly passing the filename still gives the expected errors.

To Reproduce
Create a package called test_package containing an empty __init__.py and a file called test.py with the contents:

a: int = 1
b: int = "foo"

Run the following commands:

$ dmypy run -- -p test_package
test_package/test.py:2: error: Incompatible types in assignment (expression has type "str", variable has type "int")  [assignment]
Found 1 error in 1 file (checked 2 source files)

# Comment out line 2 of test.py

$ dmypy run -- -p test_package
Success: no issues found in 2 source files

# Uncomment line 2 of test.py

$ dmypy run -- -p test_package
Success: no issues found in 2 source files

Expected Behavior
The last command should raise the "Incompatible types in assignment" error.

Actual Behavior
No issues are found, despite the contents of test.py being exactly the same as the first run.

Your Environment

  • Mypy version used: 1.13.0
  • Mypy command-line flags: (see examples above)
  • Mypy configuration options from mypy.ini (and other config files): None
  • Python version used: 3.11.6

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Reproduziere das Problem mit dmypy run -- -p test_package unter Verwendung von test_package/init.py und test_package/test.py und untersuche anschließend die Paketprüfung und das Cache-Verhalten des Daemons. Bestätige, dass der letzte Lauf nach dem Auskommentieren und anschließenden Einkommentieren der Zuweisung den Fehler zu inkompatiblen Typen erneut meldet.

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

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.