Skip to content

Run mypy with parallel workers - #9861

Open
hugovk wants to merge 2 commits into
python-pillow:mainfrom
hugovk:tox-mypy
Open

Run mypy with parallel workers#9861
hugovk wants to merge 2 commits into
python-pillow:mainfrom
hugovk:tox-mypy

Conversation

@hugovk

@hugovk hugovk commented Aug 9, 2026

Copy link
Copy Markdown
Member

mypy has added a --num-workers option:

Use NUMBER parallel worker processes (in addition to the coordinator process) to perform type-checking. Specifying --num-workers 0 (default) disables parallel checking. Automatic detection of the optimal number of workers is not supported yet.

https://mypy.readthedocs.io/en/stable/command_line.html#cmdoption-mypy-n

Here's running with some different values on an 8-core macOS:

  • Cold cache = .mypy_cache deleted
  • Warm cache = immediate re-run
--num-workers Cold cache Warm cache
(none / serial) 8.08 0.38
2 3.50 0.31
4 2.75 0.36
6 3.58 0.40
8 2.97 0.45
16 7.19 1.58

So let's go for 4.

This is mainly for local benefit, but GitHub Actions has 4 CPUs and also improves: from 20.60 seconds to 11.00 seconds.


I also sometimes have the extra test images installed, let's exclude them to avoid this:

Tests/images/sunraster/test.py:21: error: Function is missing a type annotation for one or
more parameters  [no-untyped-def]
    def test(f) -> None:
    ^~~~~~~~~~~~~~~~~~~~
Tests/images/picins/test.py:10: error: Function is missing a type annotation for one or more
parameters  [no-untyped-def]
    def test(f) -> None:
    ^~~~~~~~~~~~~~~~~~~~
Tests/images/msp/test.py:21: error: Function is missing a type annotation for one or more
parameters  [no-untyped-def]

@hugovk hugovk added the Testing label Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant