mypy
mypy
is a static type checker for Python.
Usage⚑
Pre-commit hook⚑
To use mypy
as a pre-commit hook, add:
- repo: 'https://github.com/pre-commit/mirrors-mypy'
rev: ''
hooks:
- id: 'mypy'
args: []
additional_dependencies:
- 'pydantic'
For extended support for pydantic
don't forget to add the additional dependency and enable the plugin in pyproject.toml
with:
# --------- mypy -------------
[tool.mypy]
plugins = ["pydantic.mypy"]
Tips⚑
Ignore type checking in one line⚑
To ignore type checking in one particular line of the code, add the comment # type: ignore
at the end of that line