From: Daniele Varrazzo Date: Mon, 26 Apr 2021 17:43:38 +0000 (+0100) Subject: Check test_typing with mypy as part of the pytest run X-Git-Tag: 3.0.dev0~63^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ede3145e4e16b7d165274e16e1a985dd1b58a4ed;p=thirdparty%2Fpsycopg.git Check test_typing with mypy as part of the pytest run --- diff --git a/psycopg3/setup.py b/psycopg3/setup.py index 91a39c2b4..a2fc7ab99 100644 --- a/psycopg3/setup.py +++ b/psycopg3/setup.py @@ -32,6 +32,7 @@ extras_require = { f"psycopg3-binary == {version}", ], "test": [ + "mypy >= 0.812", "pproxy >= 2.7, < 2.8", "pytest >= 6, < 6.1", "pytest-asyncio >= 0.14.0, < 0.15", diff --git a/psycopg3/tox.ini b/psycopg3/tox.ini index eff058ecd..94d2ef797 100644 --- a/psycopg3/tox.ini +++ b/psycopg3/tox.ini @@ -6,10 +6,7 @@ isolated_build = True changedir = .. commands = pytest {posargs} - 3.9: mypy tests/typing_example.py passenv = PG* PSYCOPG3_TEST_DSN PYTEST_ADDOPTS PSYCOPG3_IMPL TRAVIS* -deps = - 3.9: mypy extras = test [flake8] diff --git a/psycopg3_c/tox.ini b/psycopg3_c/tox.ini index 57ec5d4c3..523e24154 100644 --- a/psycopg3_c/tox.ini +++ b/psycopg3_c/tox.ini @@ -6,8 +6,6 @@ isolated_build = True changedir = .. commands = pytest {posargs} - 3.9: mypy tests/typing_example.py passenv = PG* PSYCOPG3_TEST_DSN PYTEST_ADDOPTS PSYCOPG3_IMPL TRAVIS* deps = -e {toxinidir}/../psycopg3[test] - 3.9: mypy diff --git a/tests/test_typing.py b/tests/test_typing.py new file mode 100644 index 000000000..95505b426 --- /dev/null +++ b/tests/test_typing.py @@ -0,0 +1,21 @@ +import os +import sys +import subprocess as sp + +import pytest + + +@pytest.mark.slow +@pytest.mark.skipif(sys.version_info < (3, 7), reason="no future annotations") +def test_typing_example(): + cmdline = f""" + mypy + --strict + --show-error-codes --no-color-output --no-error-summary + --config-file= --no-incremental --cache-dir={os.devnull} + tests/typing_example.py + """.split() + cp = sp.run(cmdline, stdout=sp.PIPE, stderr=sp.STDOUT) + errors = cp.stdout.decode("utf8", "replace").splitlines() + assert not errors + assert cp.returncode == 0