From: Daniele Varrazzo Date: Sun, 23 Mar 2025 22:10:57 +0000 (+0100) Subject: chore: configure flake8 for imports after pytest's importorskip X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=4139cf8236a1cd7af198cb903c620e4a7ad13559;p=thirdparty%2Fpsycopg.git chore: configure flake8 for imports after pytest's importorskip --- diff --git a/.flake8 b/.flake8 index b4ae65d21..79e029388 100644 --- 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 diff --git a/tests/types/test_numpy.py b/tests/types/test_numpy.py index f42e7e012..23ce25f35 100644 --- a/tests/types/test_numpy.py +++ b/tests/types/test_numpy.py @@ -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( diff --git a/tests/types/test_shapely.py b/tests/types/test_shapely.py index cd7dc259e..98fbc2052 100644 --- a/tests/types/test_shapely.py +++ b/tests/types/test_shapely.py @@ -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,