dmypy 'KeyError' on recheck
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con la riproduzione nel branch bug-dmypy-key-error, poi leggi mypy/dmypy_server.py nelle vicinanze di cmd_recheck, fine_grained_increment_follow_imports e find_reachable_changed_modules. Esegui nuovamente la sequenza ripetuta di recheck di dmypy con l’esclusione mypy.ini mostrata. L’attività è completata quando il daemon non va più in crash sui test esclusi e la regressione è coperta da un test appropriato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 52/100