Repository navigation
Upgrade mypy to 2.4.0 and optimize configuration - #79
Merged
Merged
Conversation
- Set `num_workers = "auto"` in [tool.mypy]: parallel checking is no longer experimental in 2.4, and "auto" picks the worker count from the available CPUs (capped at 8). This replaces the CI-only `--num-workers "$(nproc)"` flag, so local `mypy` runs are parallel too. dmypy forces num_workers=0, so `just lint` is unaffected. - Drop `fixed_format_cache = true`: it has been the default since mypy 2.0. - The native parser is now the default; nothing to configure. - No new documented strictness flags or error codes in 2.4 (the new `--check-unreachable` is a hidden flag), so the enable-checks list is unchanged; only the "last updated" marker moves to 2.4. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0188obxQFxxkZRKmsy9fstfd
Reports [[tool.mypy.overrides]] sections that match no checked module, e.g. a stale ignore_missing_imports for a dropped dependency. It is not part of --strict. mypy 2.4 removed the docs caveat that it requires incremental mode to be off; verified it reports with a warm cache, in parallel mode, and under dmypy. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0188obxQFxxkZRKmsy9fstfd
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="project_name/pyproject.toml.jinja" line_range="189" />
<code_context>
files = ["src", "tests"]
mypy_path = "stubs"
-fixed_format_cache = true
+num_workers = "auto"
# set the platform
python_version = "3.{{ python_min }}"
</code_context>
<issue_to_address>
**Pre-commit mypy remains serial**
When local lint is run through `just lint`, `just lint` runs `prek run --all-files`, whose mypy hook passes `--config-file ''` without a `--num-workers` option, so it ignores this setting and checks files serially. That local mypy entry point does not get the parallelism the commit says local runs gain.
Add `--num-workers=auto` to the pre-commit mypy hook if that hook is intended to share the parallelism improvement.
</issue_to_address>Sourcery assessment
Approved.
validate-pyproject (with the schema store) rejects num_workers = "auto": SchemaStore's partial-mypy.json still types num_workers as an integer, so generated projects failed `just lint`. Keep the parallel run in CI via the CLI flag, which accepts "auto" since mypy 2.4, until the schema catches up. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0188obxQFxxkZRKmsy9fstfd
tsvikas
added a commit
that referenced
this pull request
Oct 5, 2026
#79 moved this to a CI-only `--num-workers auto` flag because validate-pyproject rejects the value: SchemaStore's mypy schema still types num_workers as an integer. Put it back in [tool.mypy], so local `mypy` runs are parallel too, and disable only the mypy schema in the validate-pyproject hook until the schema catches up. Co-authored-by: Claude Opus 5.5 <[email protected]>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR upgrades mypy from version 2.3.0 to 2.4.0 and optimizes the mypy configuration to leverage the new version's capabilities.
Key Changes
~=2.3.0to~=2.4.0fixed_format_cache = truewithnum_workers = "auto"for better parallel processingwarn_unused_configs = trueto catch unused configuration options--num-workers "$(nproc)"flag from mypy invocation in CI workflow, allowing mypy to use its configurednum_workers = "auto"setting insteadImplementation Details
The
num_workers = "auto"setting allows mypy to automatically determine the optimal number of worker processes based on the system's CPU count, replacing the previous manual cache format configuration. The CI workflow now relies on the pyproject.toml configuration rather than passing command-line arguments, reducing duplication and improving maintainability.https://claude.ai/code/session_0188obxQFxxkZRKmsy9fstfd