Repository navigation
feat: add option to run mypy for Linux and Windows - #108
Open
richard-gledhill wants to merge 1 commit into
Open
richard-gledhill wants to merge 1 commit into
richard-gledhill wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a new cookiecutter option,
mypy_check_linux_and_windows(nby default).When
type_checkerismypyand this is set toy,make checkin the generated project runs mypy once per platform:With the default
n, behaviour is unchanged: a singleuv run mypy. The option has no effect whentype_checkeristy.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: newmypy_check_linux_and_windowsoption, ordered["n", "y"]so the default is unchanged.Makefiletemplate: thechecktarget now renders one of three variants (mypy, mypy on both platforms, ty).tests/test_combinations.py: newtest_makefile_type_checkerand amypy-type-checker-multi-ycombination. The test asserts on whole Makefile lines.docs/features/linting.md: new "Checking Linux and Windows" section under mypy.Notes
tyis chosen, because cookiecutter cannot skip a prompt based on an earlier answer. If you would rather avoid that, I can fold it intotype_checkerinstead (for examplemypy,mypy-multi-platform,ty).make check,make testandmake docslocally. I did not runtoxbecause the other Python versions are not installed here, so I am relying on CI for that.