gh-104050: Run mypy on `clinic.py` in CI by AlexWaygood · Pull Request #104421 · python/cpython
Add a basic mypy check to clinic.py in CI (and add some initial type annotations, so that the mypy check passes).
The check will run:
- On pushes to
main - On pull requests that touch files in the
Tools/clinicdirectory, and pull requests that touch the workflow file itself - When contributors manually request a workflow on their fork, via
workflow_dispatch.
When it does run, mypy will only check files inside Tools/clinic/. All other files will be excluded from the mypy check in CI.
The mypy configuration is also deliberately lax, to begin with: only a few of the stricter settings are enabled. This will allow us to make use of "gradual typing": mypy will only check functions inside Tools/clinic/ that we've added annotations to. It will assume all other functions are to be ignored by mypy, for now; we will therefore be able to gradually increase the level of type annotations inside this directory.