--- id: pytest-mypy-plugins version: "4.0.3" license: MIT license_treatment: permissive maintenance: active --- # pytest-mypy-plugins — pytest plugin for writing tests for mypy plugins License: permissive · Maintenance: active · Downloads: 459.5K/mo ## What it is and what it does pytest-mypy-plugins is a pytest plugin that lets you write type-checking tests in YAML format, asserting what types mypy infers for your code. Instead of manually running mypy and inspecting output, you define test cases with Python code snippets and expected type annotations inline, then run pytest to validate them. It supports both custom reveal_type matchers and standard typing.assert_type assertions, parametrized test cases, environment variables, and mypy configuration overrides. The plugin is designed for testing mypy plugins themselves, type stubs, and type-annotated libraries. It handles subprocess isolation by default (running mypy in separate processes) and provides options for same-process debugging. Test cases are written declaratively in YAML with properties like main code, extra files, mypy config, environment variables, and skip/xfail conditions, making it easy to maintain a suite of type-safety regression tests without writing boilerplate Python test code. Use it for: - Testing a custom mypy plugin by defining type-checking scenarios in YAML and verifying mypy's behavior - Validating type stubs for a library by asserting inferred types match expectations across different code patterns - Regression testing type annotations in a typed library by running a suite of type assertions as part of CI - Debugging mypy behavior by using --mypy-same-process to inspect type inference in the same Python process - Parametrized type testing by running the same type assertion across multiple input values or configurations ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. A pytest plugin that runs type-checking tests against mypy by defining test cases in YAML files with inline type assertions and custom matchers. Yes. This is a well-maintained, production-stable tool with low install friction and no known vulnerabilities. Install it if you maintain a mypy plugin, publish type stubs, or want to add type-safety regression tests to a typed library. The YAML-based test format is more readable and maintainable than writing pytest tests for type checking manually. ## Install pip install pytest-mypy-plugins uv add pytest-mypy-plugins poetry add pytest-mypy-plugins ## Installing pytest-mypy-plugins Before you install: Low friction install with a stable, actively maintained codebase. Nine runtime dependencies are all widely used and well-established (pytest, mypy, pyyaml, jsonschema, Jinja2, decorator, packaging, regex, tomlkit), and the package itself is marked Production/Stable with recent activity. License in practice: MIT license is permissive; you can use this package freely in commercial and private projects with minimal restrictions. Quickstart: pip install pytest-mypy-plugins # Create a test file (e.g., test_types.yml): # - case: simple_type_check # main: | # x = 1 # reveal_type(x) # N: Revealed type is 'builtins.int' pytest Requires Python 3.10 or later and mypy to be installed (included as a runtime dependency). Verify before relying: - Whether the plugin works with all mypy plugin types or only a subset - Performance characteristics when running large test suites with many YAML cases - Compatibility with recent mypy versions beyond what the dependency specification guarantees ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 459.5K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags mypy type testing plugin, pytest mypy integration, type checking test framework, mypy plugin testing, yaml type assertion testing, type-checking, mypy-plugin, testing-framework [View on SkillFed](https://skillfed.io/packages/pytest-mypy-plugins) · [View on PyPI](https://pypi.org/project/pytest-mypy-plugins/)