A pytest plugin for writing and running tests to verify mypy type checking behavior, stubs, and custom 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.
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.
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.
pytest plugin for testing mypy types, stubs, and plugins
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
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.
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.
Enables parameterization similar to pytest's @pytest.mark.parametrize, allowing efficient testing of multiple scenarios without code duplication, as shown in the YAML examples.
Permits setting environment variables like PYTHONPATH and MYPYPATH directly in YAML specs, facilitating testing of plugins and stubs in simulated import paths.
Provides a JSONSchema for YAML files, offering editor auto-completion and error checking to reduce mistakes in test specifications.
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.
Exclusively designed for mypy testing, making it irrelevant for projects using alternative type checkers like Pyright or pytype, limiting its broader utility.
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.