Enable mypy parallel workers in pre-commit#2185
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Align mypy and mypy-docs entries with inline --num-workers=4 usage and remove the example-workers variant. Co-authored-by: Cursor <cursoragent@cursor.com>
| name: mypy | ||
| stages: [pre-push] | ||
| entry: uv run --extra=dev -m mypy | ||
| entry: uv run --extra=dev -m mypy --num-workers=4 |
There was a problem hiding this comment.
Using mypy 2.0 flag with pinned 1.20.2 version
High Severity
The --num-workers=4 flag is a mypy 2.0 feature (parallel type checking), but the project pins mypy[faster-cache]==1.20.2 in pyproject.toml and uv.lock. Since uv run --extra=dev -m mypy resolves to the locked 1.20.2 version, both the mypy and mypy-docs hooks will fail with an unrecognized argument error. The mypy 1.20 release blog and release planning issue (#20726) confirm parallel type checking was planned exclusively for 2.0.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit f455ade. Configure here.
Skip the pre-commit-ci lite-action during PR runs so lint checks don't fail on stale cherry-pick conflicts, while preserving autofix behavior on push workflows. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b43fa4d. Configure here.
| stages: [pre-push] | ||
| entry: uv run --extra=dev doccmd --no-write-to-file --language=python --command="mypy" | ||
| entry: uv run --extra=dev doccmd --no-write-to-file --language=python --command="mypy | ||
| --num-workers=4" |
There was a problem hiding this comment.
Doc parallelization uses wrong flag
Medium Severity
The mypy-docs hook adds mypy --num-workers=4 inside doccmd --command, but the PR goal is parallel doc-example runs via doccmd --example-workers 4. num-workers only parallelizes work inside one mypy process; doccmd still runs each extracted snippet largely serially, so the intended docs speedup is missing.
Reviewed by Cursor Bugbot for commit b43fa4d. Configure here.


Summary
mypy-docsviadoccmd --example-workers 4mypyinvocation compatible with current mypy CLI while fixing doccmd hook wiringuvas an explicitmypy-docshook dependency for consistent hook environment resolutionTest plan
pre-commit run --hook-stage pre-push mypy --all-filespre-commit run --hook-stage pre-push mypy-docs --all-filesMade with Cursor
Note
Low Risk
Low risk: only updates pre-commit hook commands/dependencies, with the main downside being potential flakiness or resource contention from parallel mypy runs on some machines.
Overview
Pre-push mypy hooks now run in parallel. The
mypypre-commit hook is updated to invokemypy --num-workers=4.Docs type-checking is aligned with the same parallelism and environment. The
mypy-docshook’sdoccmdcommand is rewired to passmypy --num-workers=4and now explicitly includesuvviaadditional_dependenciesfor consistent hook resolution.Reviewed by Cursor Bugbot for commit b43fa4d. Bugbot is set up for automated code reviews on this repo. Configure here.