{"id":7617,"library":"pytest-mypy-plugins","title":"pytest-mypy-plugins","description":"pytest-mypy-plugins is a pytest plugin designed for writing tests for mypy plugins, stubs, and type definitions. It allows developers to verify the correctness of their type annotations and mypy plugin behavior directly within their pytest test suite. The library is actively maintained, with releases as needed, and the current version is 4.0.1.","status":"active","version":"4.0.1","language":"python","source_language":"en","source_url":"https://github.com/TypedDjango/pytest-mypy-plugins","tags":["pytest","mypy","testing","type checking","plugins","static analysis"],"install":[{"cmd":"pip install pytest-mypy-plugins","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"This is a pytest plugin and integrates with pytest's test discovery and execution. Requires pytest>=7.0.0.","package":"pytest","optional":false},{"reason":"The plugin tests mypy types, stubs, and plugins. It integrates directly with the mypy type checker. Supports mypy@1.8.0 and later versions.","package":"mypy"}],"imports":[{"note":"pytest plugins are typically auto-discovered upon installation. For advanced configuration, one might access the plugin via `config.pluginmanager.getplugin('mypy')` in `conftest.py`.","symbol":"pytest-mypy-plugins","correct":"No explicit import usually needed, automatically discovered by pytest."}],"quickstart":{"code":"# Save as my_module.py\ndef add(a: int, b: int) -> int:\n    return a + b\n\n# Save as test_types.yml in a directory like 'typesafety/'\n- case: correct_addition\n  main: |\n    from my_module import add\n    result = add(1, 2)\n    reveal_type(result) # N: Revealed type is 'builtins.int'\n\n- case: incorrect_addition_type\n  main: |\n    from my_module import add\n    add(1, '2') # E: Argument 2 to \"add\" has incompatible type \"str\"; expected \"int\" [arg-type]\n\n# To run tests, simply execute pytest in your terminal from the project root:\n# pytest","lang":"python","description":"Create a Python file (`my_module.py`) with code to be type-checked, and a YAML file (`test_types.yml`) defining test cases. Each `case` block in the YAML file contains `main` (Python code) and uses `# N:` for expected `reveal_type` output or `# E:` for expected mypy error messages. The plugin automatically discovers and runs these tests when `pytest` is executed."},"warnings":[{"fix":"The `--mypy-only-local-stub` flag was removed. To restore the previous behavior of checking errors in site-packages, use the new `--mypy-no-silence-site-packages` flag.","message":"Errors are now ignored in site-packages by default starting from version 4.0.0.","severity":"breaking","affected_versions":"4.0.0 and later"},{"fix":"Ensure your test environment uses Python 3.9 or newer. Python 3.13 support was officially added in 3.3.0.","message":"Python 3.8 support was dropped in versions 3.2.0 and 3.3.0.","severity":"breaking","affected_versions":"3.2.0, 3.3.0 and later"},{"fix":"Upgrade your Python environment to Python 3.8 or newer. The minimum Python requirement for the latest versions is `>=3.10`.","message":"Python 3.7 support was dropped starting from version 3.0.0.","severity":"breaking","affected_versions":"3.0.0 and later"},{"fix":"Either invoke `pytest` with `--mypy-same-process` to run `mypy` in the same process, or use absolute paths for `PYTHONPATH` and `MYPYPATH` to ensure correct referencing.","message":"Relative paths in `PYTHONPATH` or `MYPYPATH` environment variables may not work as expected when `mypy` runs in a subprocess (the default mode for the plugin).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'4.0.1':59 'activ':48 'allow':25 'analysi':67 'annot':34 'behavior':38 'check':64 'correct':30 'current':56 'definit':23 'design':13 'develop':26 'direct':39 'librari':46 'maintain':49 'mypi':3,7,18,36,61 'need':53 'plugin':4,8,12,19,37,65 'pytest':2,6,11,42,60 'pytest-mypy-plugin':1,5 'releas':51 'static':66 'stub':20 'suit':44 'test':16,43,62 'type':22,33,63 'verifi':28 'version':57 'within':40 'write':15","created_at":"2026-04-16T14:06:03.814995+00:00","updated_at":"2026-04-16T14:06:03.814995+00:00","problems":{"verify_error":"no import statement found"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"4.0.3","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/TypedDjango/pytest-mypy-plugins","docs":null,"changelog":null,"pypi":"https://pypi.org/project/pytest-mypy-plugins/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing","type-stubs"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"skip","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-05","install_tag":null}}