skillfed

pytest-mypy

A Pytest Plugin for Mypy

pytest-mypy v1.0.1 557.3K downloads/30d#6,011 on PyPI256
Permissive 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) Active released

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-mypy

uv

uv add pytest-mypy

poetry

poetry add pytest-mypy

Installing 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

Development Status :: 5 - Production/StableFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonTopic :: Software Development :: Testing

Tags

pytest mypy pluginstatic type checking pytestmypy integration testingtype checking in test runspytest type checkermypy pytest integration
type-checkingpytest-pluginci-integration

More Testing packages