Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit 3592276c authored by Dorian Turba's avatar Dorian Turba
Browse files

add mypy

parent 455b2bfd
No related branches found
No related tags found
No related merge requests found
files:
template: ./python/code_quality/mypy/mypy.yml
documentation: ./python/code_quality/mypy/README.md
data:
description: "Run mypy on your repository"
icon: 💎
public: true
labels:
- Static TypeChecking
- Utilities
- Code Quality
- Python
- TypeChecker
license: MIT
deprecated: false
## Objective
Run [mypy](https://mypy.readthedocs.io/en/stable/) 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.
### 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](https://mypy.readthedocs.io/en/stable/config_file.html) files.
## How to use it
1. Configure the `mypy.ini`, `setup.cfg` or `pyproject.toml` file in your repository's root directory with your
desired rules.
2. Include the mypy template in your CI/CD configuration (see quick use above).
3. If you need to customize the job, check
the [jobs customization](https://docs.r2devops.io/get-started/use-templates/#job-templates-customization).
## Add a <a href="https://mypy.readthedocs.io/"><img alt="Type Checked: mypy" src="https://img.shields.io/badge/mypy-checks-blue"></a> Badge to your project README.md
To display the use of mypy in your project, you can add the following badge to your README.md:
```markdown
<a href="https://mypy.readthedocs.io/">
<img alt="Type Checked: mypy" src="https://img.shields.io/badge/mypy-checks-blue">
</a>
```
mypy:
image: python:latest
stage: code_quality
script:
- python --version # Debug
- python -m venv venv --upgrade-deps || python -m venv venv # upgrade-deps is not supported before 3.9
- source venv/bin/activate
- pip install mypy
- mypy
only:
changes:
- ./**/*.py
- .gitlab-ci.yml
- pyproject.toml
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment