Project: pytest-mypy

Mypy static type checker plugin for Pytest

Project Details

Latest version
0.10.3
Home Page
https://github.com/dbader/pytest-mypy
PyPI Page
https://pypi.org/project/pytest-mypy/

Project Popularity

PageRank
0.003929771049604087
Number of downloads
161222

pytest-mypy

Mypy static type checker plugin for pytest

.. image:: https://img.shields.io/pypi/v/pytest-mypy.svg :target: https://pypi.org/project/pytest-mypy/ :alt: See Latest Release on PyPI

Features

  • 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.

Installation

You can install "pytest-mypy" via pip_ from PyPI_:

.. code-block:: bash

$ pip install pytest-mypy

Usage

You can enable pytest-mypy with the --mypy flag:

.. code-block:: bash

$ py.test --mypy test_*.py

Mypy supports reading configuration settings <http://mypy.readthedocs.io/en/latest/config_file.html>_ from a mypy.ini file. Alternatively, the plugin can be configured in a conftest.py to invoke mypy with extra options:

.. code-block:: python

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:

.. code-block:: bash

py.test --mypy -m mypy test_*.py

License

Distributed under the terms of the MIT_ license, "pytest-mypy" is free and open source software

Issues

If you encounter any problems, please file an issue_ along with a detailed description.

Meta

Daniel Bader – @dbader_org_ – https://dbader.org – mail@dbader.org

https://github.com/dbader/pytest-mypy

.. _MIT: http://opensource.org/licenses/MIT .. _file an issue: https://github.com/dbader/pytest-mypy/issues .. _pip: https://pypi.python.org/pypi/pip/ .. _PyPI: https://pypi.python.org/pypi .. _mypy: http://mypy-lang.org/ .. _pytest-flake8: https://pypi.python.org/pypi/pytest-flake8 .. _flake8: https://pypi.python.org/pypi/flake8 .. _@dbader_org: https://twitter.com/dbader_org