Objective
Run mypy on your Python code to perform static typing
checks, ensuring better code reliability and readability. mypy
is a Python tool that checks the
types of variables, function return values, and more.
How to use it
- Configure the
mypy.ini
,setup.cfg
orpyproject.toml
file in your repository's root directory with your desired rules. - Include the mypy template in your CI/CD configuration (see quick use above).
- If you need to customize the job, check the jobs customization.
Variables
Name | Description | Default |
---|---|---|
PROJECT_PATH |
The path to the project root directory. | "." |
IMAGE_TAG |
The default tag for the docker image. See Python Docker Official Image for supported tags and respective Dockerfile links. | "latest" |
PYTHON_SETUP |
Bash commands to setup your python environment. | "pip install mypy" |
Global Configuration of mypy
To add configuration to mypy
shared with any other usage of mypy (such as manual run, pre-commit,
etc), you can use mypy.ini
, setup.cfg
or pyproject.toml
configuration file. Learn more
about mypy configuration files.
badge to your project README.md
Add a To display the use of mypy in your project, you can add the following badge to your README.md:
[](https://mypy.readthedocs.io/)