mypy#

mypy is a static type checker for Python. It helps catch type errors before runtime, improving code safety and maintainability. This template configures mypy as part of the QA process, and you can run it with:

hatch run type

Configuration#

Mypy settings are defined in the [tool.mypy] section of pyproject.toml. You can customize strictness, ignored files, and more.

Further Reading#

Alternatives#

Other static type checkers for Python include:

  • Pyright: Fast type checker, also powers VS Code’s Python extension.

  • Pyre: Type checker from Meta, focused on speed and scalability.