Stop passing `--threads` to `pyright` by default in `make typecheck`
This pull request was posted by Claude Code using claude-opus-5 on behalf of David.
David specified the change and the measurements behind it; he has not reviewed the diff line by line.
Why we make these changes
#7857 gave make typecheck-pyright a bare --threads, so pyright forks one worker per logical
core. Every worker is a full Node process, which is a good trade on a runner and a bad one on a
laptop already near its memory limit: it swaps instead of parallelising. Measured on a 10-core 24GB
Mac, every run reporting 0 errors, the ten workers took 91-108s over 5 runs where a single
process took 33-41s over 4.
The flag is worth keeping where the memory exists. That step's absolute cost drifts through the
day, so comparing across days is useless; within one evening, on pull-request runs, the
quality checks pre-commit step took 475s, 499s, 519s and 520s on branches carrying --threads
against 607s and 636s on this branch without it. So CI opts back in by name rather than inheriting
a default meant for a laptop.
That leaves the default where a machine's memory is unknown: unset, pyright's own single-process
check. PYRIGHT_THREADS — this PR's original subject — is how a machine with the memory opts in.
New public surface
None. PYRIGHT_THREADS is a Makefile variable, unset by default.
User-visible behavior
$ make -n typecheck-pyright
PYRIGHT_PYTHON_IGNORE_WARNINGS=1 uv run pyright
$ PYRIGHT_THREADS=auto make -n typecheck-pyright
PYRIGHT_PYTHON_IGNORE_WARNINGS=1 uv run pyright --threads auto
A positive integer caps the workers instead. ?= yields to the environment and to the command line,
and PYRIGHT_PYTHON still composes.
1 is the only other single-process spelling: parseThreadsArgValue sends auto, 0, off
and anything else it cannot read as a positive integer to os.cpus().length, so the Makefile
comment and the docs both name that boundary now that unset is the off switch.
Verification
Every spelling dry-run through make -n, and each one run for real against a single file under
--verbose: only --threads 1 omits pyright's Using N threads line. scripts/typecheck_changed.py
already omitted --threads on its narrowed run, so only its comment moved, and
scripts/test_typecheck_changed.py writes its own Makefile, so no test asserts on the flag.
Makefile and .github/workflows/ci.yml are both pyright_changed inputs, so this PR's own CI runs
the full type check through the rewritten recipe.
What changes for existing users
A developer who sets nothing gets a single pyright process, as before #7857; PYRIGHT_THREADS=auto
restores the parallel run. CI is unchanged — it now asks for the workers by name.
Checklist
- Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
- No breaking changes in accordance with the version policy.
- PR title is fit for the release changelog.