-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
Description
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 #18906
relates to #18755