dmypy 'KeyError' on recheck
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Crash Report
Running dmypy multiple times results in a KeyError. The error is always on files we exclude in our mypy.ini.
Traceback
[nick@Mac] ~/workspace/mypy-playground [bug-dmypy-key-error]
$ uv run dmypy start -- --show-traceback
Daemon started
[nick@Mac] ~/workspace/mypy-playground [bug-dmypy-key-error]
$ uv run dmypy check src/
src/mypy_playground/example.py:3: error: Name "x" already defined on line 1 [no-redef]
Found 1 error in 1 file (checked 2 source files)
[nick@Mac] ~/workspace/mypy-playground [bug-dmypy-key-error]
$ uv run dmypy recheck
src/mypy_playground/example.py:3: error: Incompatible import of "x" (imported name has type "int", local name has type "str") [assignment]
Found 1 error in 1 file (checked 61 source files)
[nick@Mac] ~/workspace/mypy-playground [bug-dmypy-key-error]
$ uv run dmypy recheck
Daemon crashed!
Traceback (most recent call last):
File "mypy/dmypy_server.py", line 237, in serve
File "mypy/dmypy_server.py", line 286, in run_command
File "mypy/dmypy_server.py", line 408, in cmd_recheck
File "mypy/dmypy_server.py", line 629, in fine_grained_increment_follow_imports
File "mypy/dmypy_server.py", line 768, in find_reachable_changed_modules
KeyError: 'mypy_playground.tests'
To Reproduce
Pushed example source code to https://github.com/njgrisafi/mypy-playground/ on branch bug-dmypy-key-error
See the README https://github.com/njgrisafi/mypy-playground/tree/bug-dmypy-key-error
Your Environment
- Mypy version used: 1.18.2 & 1.16.0
- Mypy command-line flags:
dmypy start,dmypy check src/anddmypy recheck - Mypy configuration options from
mypy.ini(and other config files):
[mypy]
check_untyped_defs = True
ignore_missing_imports = True
no_implicit_optional = True
allow_untyped_globals = True
local_partial_types = True
enable_error_code = ignore-without-code
follow_imports = normal
warn_unused_configs = True
warn_redundant_casts = True
no_warn_no_return = True
disallow_untyped_defs = False
disable_error_code =
has-type,
annotation-unchecked,
misc
mypy_path = src
files = src/mypy_playground/
exclude = (?x)(
\./.* # dot-prefixed files
| tests
) # (intentional whitespace, otherwise it errors)
[mypy-tests.*,*.tests.*,*.unit_tests.*,*.unit_test.*,*.integration_tests.*,conftest_integration]
ignore_errors = True
follow_imports = skip
- Python version used: 3.12.11
- Operating system and version: macOS Tahoe 26.1
I suspect it can be related to https://github.com/python/mypy/pull/18906
relates to https://github.com/python/mypy/issues/18755
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 Reproduktion im Branch bug-dmypy-key-error und lies dann in mypy/dmypy_server.py den Bereich um cmd_recheck, fine_grained_increment_follow_imports und find_reachable_changed_modules. Führe die wiederholte dmypy-recheck-Sequenz mit dem gezeigten mypy.ini-Ausschluss erneut aus. Erledigt ist die Aufgabe, wenn der Daemon bei den ausgeschlossenen Tests nicht mehr abstürzt und die Regression durch einen geeigneten Test abgedeckt 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
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 52/100