]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Check test_typing with mypy as part of the pytest run
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 26 Apr 2021 17:43:38 +0000 (18:43 +0100)
committerDenis Laxalde <denis.laxalde@dalibo.com>
Wed, 28 Apr 2021 13:08:48 +0000 (15:08 +0200)
psycopg3/setup.py
psycopg3/tox.ini
psycopg3_c/tox.ini
tests/test_typing.py [new file with mode: 0644]

index 91a39c2b45720696b6e40c908520a1f6621e41d2..a2fc7ab9915b36cd7df3818786834fe3341bd26a 100644 (file)
@@ -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",
index eff058ecd509db7f56e03f0888a7d66c1009dd14..94d2ef7977ce62dd4a147ebb6bb7a3b3dda4374f 100644 (file)
@@ -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]
index 57ec5d4c34ec42614df2d3cb293b7bb51caca546..523e2415490870351573007373b3f62468afc92f 100644 (file)
@@ -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 (file)
index 0000000..95505b4
--- /dev/null
@@ -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