pytest-mypy
A Pytest Plugin for Mypy
What it is and what it does
pytest-mypy is a pytest plugin that runs mypy's static type checker on your source files as part of your normal pytest test runs. Instead of running type checks separately, you invoke mypy checks through pytest using the --mypy flag, making type validation part of your continuous test workflow.
The plugin works by integrating mypy into pytest's test discovery and execution, similar to how pytest-flake8 integrates flake8. You can configure mypy behavior through a mypy.ini file or programmatically in conftest.py, and you can filter test runs to only perform type checks using pytest's -m option. It depends on pytest, mypy, and filelock, all of which are common tools in Python development environments.
Use it for:
- Run type checks automatically as part of your CI/CD pipeline without a separate mypy invocation step.
- Enforce type checking discipline in test suites by failing the build when type errors are detected.
- Configure mypy options per-project in conftest.py to apply custom type-checking rules during test runs.
- Restrict test execution to only type checks using pytest markers when you want to validate types without running functional tests.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Integrates mypy static type checking into pytest, running type checks on your source files as part of your test suite.
Yes. The package is actively maintained, has low install friction, carries a permissive MIT license, and solves a real workflow problem—integrating type checking into your existing pytest test runs. It's well-suited for teams that want type validation as a first-class part of their test suite rather than a separate tool invocation.
Install
pytest-mypy on PyPI
pip
pip install pytest-mypyuv
uv add pytest-mypypoetry
poetry add pytest-mypyInstalling pytest-mypy
Before you install
Low friction install with three straightforward runtime dependencies (pytest, mypy, filelock). The package is actively maintained with recent commits and has been stable since its early releases.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
Quickstart
pip install pytest-mypy
py.test --mypy test_*.py
# Or configure in conftest.py:
def pytest_configure(config):
plugin = config.pluginmanager.getplugin('mypy')
plugin.mypy_argv.append('--check-untyped-defs')
Requires mypy and pytest to be installed; mypy configuration can be read from mypy.ini or set programmatically via conftest.py.
Verify before relying
- Whether the plugin supports all mypy configuration options or only a subset
- Performance impact when running type checks on large codebases during test execution
Package facts
| License | The MIT License (MIT) Copyright (c) 2016 Daniel Bader Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — filelock, mypy, pytest |
| Maintenance | actively maintained — 499 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 557,278/month — #6,011 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_mypy-1.0.1-py3-none-any.whl
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
pytest-flake8A pytest plugin that runs flake8 PEP8…
permissive · top 15,000 on PyPI
pytest-loggerPytest-logger is a pytest plugin that…
permissive · top 15,000 on PyPI
pytest-datadirA pytest plugin that provides fixtures for…
permissive · top 5,000 on PyPI
mypyMypy is a static type checker for Python that…
permissive · top 1,000 on PyPI
pytest-loggingA pytest plugin that configures Python logging…
permissive · top 15,000 on PyPI
pytest-enablerA pytest plugin that conditionally enables…
permissive · top 15,000 on PyPI
pytest-astropy-headerA pytest plugin that automatically includes…
permissive · top 15,000 on PyPI
pytest-test-groupspytest-test-groups is a pytest plugin that…
permissive · top 5,000 on PyPI
pytest-progressA pytest plugin that displays real-time test…
permissive · top 15,000 on PyPI
pytest-metadataA pytest plugin that captures and exposes test…
copyleft · top 1,000 on PyPI