]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
chore: configure flake8 for imports after pytest's importorskip
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 23 Mar 2025 22:10:57 +0000 (23:10 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 26 Mar 2025 14:19:52 +0000 (15:19 +0100)
.flake8
tests/types/test_numpy.py
tests/types/test_shapely.py

diff --git a/.flake8 b/.flake8
index b4ae65d212e24c84f6a4050734882ae140947b52..79e029388048c5ca75725c6bd2ad3353bacc472f 100644 (file)
--- a/.flake8
+++ b/.flake8
@@ -13,3 +13,7 @@ per-file-ignores =
 
     # Allow concatenated string literals from async_to_sync
     psycopg_pool/psycopg_pool/pool.py: E501
+
+    # Pytest's importorskip() getting in the way
+    tests/types/test_numpy.py: E402
+    tests/types/test_shapely.py: E402
index f42e7e012cf4cf8124aaf0dca3aeee0d2c5f2e10..23ce25f357a9906e46cabed82b2e10c6b9594181 100644 (file)
@@ -7,13 +7,10 @@ from packaging.version import parse as ver  # noqa: F401  # used in skipif
 from psycopg.pq import Format
 from psycopg.adapt import PyFormat
 
-try:
-    import numpy as np
-except ImportError:
-    pass
-
 pytest.importorskip("numpy")
 
+import numpy as np
+
 pytestmark = [pytest.mark.numpy]
 
 skip_numpy2 = pytest.mark.skipif(
index cd7dc259e3fc6c3dbc20629e690e94a8669f859d..98fbc2052d888ee8d0d081b5869cbc8e0049ba0d 100644 (file)
@@ -7,9 +7,9 @@ from psycopg.types import TypeInfo
 
 pytest.importorskip("shapely")
 
-from shapely.geometry import MultiPolygon, Point, Polygon  # noqa: E402
+from shapely.geometry import MultiPolygon, Point, Polygon
 
-from psycopg.types.shapely import register_shapely  # noqa: E402
+from psycopg.types.shapely import register_shapely
 
 pytestmark = [
     pytest.mark.postgis,