Mypy static type checker plugin for pytest
- Runs the mypy static type checker on your source files as part of your pytest test runs.
- Does for mypy what the pytest-flake8 plugin does for flake8.
- This is a work in progress – pull requests appreciated.
$ pip install pytest-mypy
You can enable pytest-mypy with the
$ py.test --mypy test_*.py
Mypy supports reading configuration settings from a
Alternatively, the plugin can be configured in a
conftest.py to invoke mypy with extra options:
def pytest_configure(config): plugin = config.pluginmanager.getplugin('mypy') plugin.mypy_argv.append('--check-untyped-defs')
You can restrict your test run to only perform mypy checks and not any other tests by using the -m option:
py.test --mypy -m mypy test_*.py
Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.
Development Environment Setup
Here's how to install pytest-mypy in development mode so you can test your changes locally:
$ pyvenv venv $ source venv/bin/activate $ python setup.py develop $ venv/bin/py.test --mypy example_test.py
How to publish a new version to PyPI
$ pip install twine wheel $ python setup.py sdist bdist_wheel $ twine upload dist/*
Distributed under the terms of the MIT license, "pytest-mypy" is free and open source software
If you encounter any problems, please file an issue along with a detailed description.