python / python/mypy

Mypy does not recheck files when follow_imports changes for dependencies

Offen
#7,777 3 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug priority-0-high topic-fine-grained-incremental
Vorherrschende Sprache
Python
Sterne
20.6k
Forks
3.3k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

Steps to reproduce
  1. Create module test.py with import from nonexistent module:
from foo import bar
  1. Create mypy.ini file:
[mypy]

[mypy-foo]
ignore_missing_imports = True 
  1. Run mypy
$ mypy test.py 
Success: no issues found in 1 source file
  1. Comment out [mypy-foo] section in mypy.ini
[mypy]

# [mypy-foo]
# ignore_missing_imports = True 
  1. Run mypy
$ mypy test.py 
Success: no issues found in 1 source file
Expected result

After step 4, mypy should detect config change and (partially?) invalidate cache, leading to a type error.

$ mypy test.py 
test.py:1: error: Cannot find module named 'foo'
test.py:1: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)
Notes
  • Deleting .mypy_cache/ and re-running mypy fixes the issue.
  • Adding/removing ignore_missing_imports in the main [mypy] section does seem to invalidate the cache as expected. So this issue only seems to apply to [mypy-PATTERN] sections.
Versions
$ python --version
Python 3.7.3
$ mypy --version
mypy 0.740

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 test.py, mypy.ini und dem Verzeichnis .mypy_cache/ anhand der gezeigten Konfigurationsschritte. Beginne damit, die Cache-Invalidierung für Abschnitte [mypy-PATTERN] nachzuverfolgen, und vergleiche sie mit Änderungen im Hauptabschnitt [mypy]. Als erledigt gilt die Aufgabe, wenn eine Änderung am Pattern-Abschnitt dazu führt, dass mypy das fehlende Modul foo meldet, ohne den Cache manuell zu löschen.

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
48/100

Neue Issues direkt in Ihr Postfach

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