Skip to content

Pydantic Mypy Plugin

Pydantic works well with mypy right out of the box.

However, Pydantic also ships with a mypy plugin that adds a number of important pydantic-specific features to mypy that improve its ability to type-check your code.

Enabling the Plugin

To enable the plugin, just add pydantic.mypy to the list of plugins in your mypy config file (this could be mypy.ini or setup.cfg).

To get started, all you need to do is create a mypy.ini file with following contents:

[mypy]
plugins = pydantic.mypy

See the mypy usage and plugin configuration docs for more details.

References