Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Pytest and mypy

pip install mypy
pip install pytest-mypy

mypy mymod.py

pytest --mypy
import sys

z = "23"
z = int(z)

def add(x, y):
   return x + y
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

{% embed include file="src/examples/pytest/mypy/mypy.ini)

Not even this:

{% embed include file="src/examples/pytest/mypy/pytest.ini)