Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Typing
  3. pytest-mypy-plugins

pytest-mypy-plugins

MITPython4.0.3

A pytest plugin for writing and running tests to verify mypy type checking behavior, stubs, and custom plugins.

Visit WebsiteGitHubGitHub
126 stars32 forks0 contributors

What is pytest-mypy-plugins?

pytest-mypy-plugins is a pytest plugin designed for testing mypy's type checking functionality. It allows developers to write test cases in YAML format to verify that mypy correctly infers types, validates custom stubs, and works with plugins. This tool is essential for ensuring that type annotations and mypy configurations behave as intended across different code scenarios.

Target Audience

Python developers and library maintainers who use mypy for static type checking and need to test custom type stubs, plugins, or complex type annotations. It is particularly useful for projects with extensive type definitions or those developing mypy plugins.

Value Proposition

Developers choose pytest-mypy-plugins because it integrates seamlessly with pytest, providing a familiar testing workflow while offering a specialized framework for type safety validation. Its YAML-based test specification makes it easy to write and maintain comprehensive type tests, reducing the risk of type-related bugs.

Overview

pytest plugin for testing mypy types, stubs, and plugins

Use Cases

Best For

  • Testing custom mypy plugins for correct type inference
  • Validating type stubs for third-party libraries
  • Ensuring complex type annotations behave as expected in large codebases
  • Automating type safety checks in CI/CD pipelines
  • Writing parametrized tests for multiple type scenarios
  • Debugging mypy configuration and environment issues

Not Ideal For

  • Projects that do not use mypy or any static type checking
  • Teams preferring to write type tests directly in Python code rather than YAML specifications
  • Environments using unittest or other testing frameworks instead of pytest
  • Simple type validation where running mypy on source files is sufficient without automated test suites

Pros & Cons

Pros

YAML Test Specification

Allows writing test cases in a simple YAML format with code snippets and expected mypy outputs, making it easy to define and maintain comprehensive type tests.

Flexible Type Assertions

Supports both custom reveal_type for detailed output matching and standard typing.assert_type, providing multiple ways to verify type inferences based on project needs.

Parametrized Testing Support

Enables parameterization similar to pytest's @pytest.mark.parametrize, allowing efficient testing of multiple scenarios without code duplication, as shown in the YAML examples.

Environment Configuration

Permits setting environment variables like PYTHONPATH and MYPYPATH directly in YAML specs, facilitating testing of plugins and stubs in simulated import paths.

Schema Validation

Provides a JSONSchema for YAML files, offering editor auto-completion and error checking to reduce mistakes in test specifications.

Cons

Path Configuration Hassles

Relative paths for PYTHONPATH or MYPYPATH often fail when mypy runs in a subprocess, requiring absolute paths or same-process mode, which complicates setup and debugging.

Niche to Mypy

Exclusively designed for mypy testing, making it irrelevant for projects using alternative type checkers like Pyright or pytype, limiting its broader utility.

YAML Learning Curve

Relies on YAML files for test definitions, which can be less intuitive and harder to debug for developers accustomed to writing tests in Python with standard IDE tools.

Frequently Asked Questions

Quick Stats

Stars126
Forks32
Contributors0
Open Issues21
Last commit3 days ago
CreatedSince 2018

Tags

#developer-tools#pytest#mypy-stubs#python-testing#type-safety#pep484#python#mypy#type-checking#yaml-tests#mypy-plugins#pytest-plugin#static-analysis

Built With

Y
YAML
P
Python
p
pytest

Links & Resources

Website

Included in

Typing2.0k
Auto-fetched 15 hours ago

Related Projects

pytest-mypypytest-mypy

Mypy static type checker plugin for Pytest

Stars256
Forks33
Last commit1 month ago
pytest-mypy-testingpytest-mypy-testing

pytest plugin to test mypy static type analysis

Stars34
Forks10
Last commit5 months ago
mypy-testmypy-test

Test mypy plugins, stubs, custom types.

Stars6
Forks2
Last commit2 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub