Run the mypy pre-commit hook the same way as CI#6977
Merged
Conversation
14 tasks
mypy is a whole-program checker, but the pre-commit hook passed only the changed files (with pass_filenames on) and added --ignore-missing-imports, neither of which matches the CI command (mypy supervisor). Passing only the changed files gives results that differ from a full run, and because pre-commit splits a long file list and runs the hook concurrently, the parallel mypy processes race on the shared SQLite cache that is enabled by default since mypy 2.0 and crash with intermittent INTERNAL ERRORs (python/mypy#21525). --ignore-missing-imports is also redundant: the [tool.mypy] config already disables the import-not-found and import-untyped error codes. Set pass_filenames: false so the hook always checks the whole supervisor package in a single invocation, add require_serial: true as a safeguard, and drop --ignore-missing-imports so the hook matches mypy supervisor. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
cf09261 to
45265d4
Compare
mdegat01
approved these changes
Jun 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed change
Run the
mypypre-commit hook the same way CI does, withmypy supervisor.mypy is a whole-program checker, but the hook was configured to check only the changed files (the default
pass_filenamesbehavior) and added--ignore-missing-imports. Neither matches the CI command (mypy supervisor), which leads to two problems:INTERNAL ERRORcrashes. When severalsupervisor/files change, pre-commit splits the file list and runs the hook concurrently. Since mypy 2.0 the SQLite cache is enabled by default, and the parallel mypy processes race on the shared.mypy_cache/cache.db: SQLite reportsdatabase is locked(python/mypy#21525), and an interrupted write can leave the databasemalformed. This is the failure mode that the cache-cleanup runbook in Add mypy cache-fix skill documentation #6971 works around; this PR addresses the root cause instead.The fix aligns the hook with CI:
pass_filenames: falseand an explicitsupervisortarget so the hook always checks the whole package in a single invocation.require_serial: trueas a safeguard against pre-commit ever running the hook concurrently.--ignore-missing-imports, which CI does not use and which is redundant anyway:[tool.mypy]already disables theimport-not-foundandimport-untypederror codes.Type of change
Additional information
Checklist
ruff format supervisor tests)If API endpoints or add-on configuration are added/changed: