Skip to content

feat: add option to run mypy for Linux and Windows - #108

Open
richard-gledhill wants to merge 1 commit into
osprey-oss:mainfrom
richard-gledhill:feat/update-make-static-type-checking
Open

richard-gledhill wants to merge 1 commit into
osprey-oss:mainfrom
richard-gledhill:feat/update-make-static-type-checking

Conversation

@richard-gledhill

Copy link
Copy Markdown

What

Adds a new cookiecutter option, mypy_check_linux_and_windows (n by default).

When type_checker is mypy and this is set to y, make check in the generated project runs mypy once per platform:

uv run mypy --platform linux
uv run mypy --platform win32

With the default n, behaviour is unchanged: a single uv run mypy. The option has no effect when type_checker is ty.

Why

mypy checks code against a single platform, so branches guarded by sys.platform == "win32" (or "linux") are skipped on the other OS. Running mypy for both platforms catches type errors in platform-specific code, which matters for projects that support Linux and Windows.

This is an opt-in option for a fairly narrow case: projects with platform-specific code paths that need to type-check on both Linux and Windows. It is off by default, so projects that don't need it see no change, and it increases mypy's runtime when enabled.

Changes

  • cookiecutter.json: new mypy_check_linux_and_windows option, ordered ["n", "y"] so the default is unchanged.
  • Makefile template: the check target now renders one of three variants (mypy, mypy on both platforms, ty).
  • tests/test_combinations.py: new test_makefile_type_checker and a mypy-type-checker-multi-y combination. The test asserts on whole Makefile lines.
  • docs/features/linting.md: new "Checking Linux and Windows" section under mypy.

Notes

  • The option is prompted for even when ty is chosen, because cookiecutter cannot skip a prompt based on an earlier answer. If you would rather avoid that, I can fold it into type_checker instead (for example mypy, mypy-multi-platform, ty).
  • I ran make check, make test and make docs locally. I did not run tox because the other Python versions are not installed here, so I am relying on CI for that.

@richard-gledhill richard-gledhill changed the title Add option to run mypy for Linux and Windows feat: add option to run mypy for Linux and Windows Oct 22, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant