Pytest and mypy



pip install mypy
pip install pytest-mypy

mypy mymod.py

pytest --mypy


examples/pytest/mypy/mymod.py
import sys

z = "23"
z = int(z)

def add(x, y):
   return x + y

examples/pytest/mypy/test_mymod.py
import mymod

x = "23"
x = int(x)

def test_add():
    assert mymod.add(2, 3) == 5

Excluding files when using mypy works, but that does not exclude them when using pytest --mypy


examples/pytest/mypy/mypy.ini
[mypy]
exclude=test_mymod.py

Not even this:


examples/pytest/mypy/pytest.ini
[mypy]
exclude=test_mymod.py