From 53e9063abde8737e0c41db2da2e29c160b42840b Mon Sep 17 00:00:00 2001 From: Stefaan Lippens Date: Fri, 4 Aug 2023 18:54:15 +0200 Subject: [PATCH] Issue #197 chore: import cleanup in feature branch using `darker -v -i -r master openeo_driver tests` --- openeo_driver/datacube.py | 14 +++++++------- openeo_driver/processes.py | 8 ++++---- openeo_driver/testing.py | 14 ++++++-------- openeo_driver/util/geometry.py | 2 +- tests/test_delayed_vector.py | 3 ++- tests/test_testing.py | 7 +++---- tests/test_vectorcube.py | 6 +++--- tests/test_views_execute.py | 2 +- tests/util/test_geometry.py | 16 +++++++--------- 9 files changed, 34 insertions(+), 38 deletions(-) diff --git a/openeo_driver/datacube.py b/openeo_driver/datacube.py index 4968b414..6bed712f 100644 --- a/openeo_driver/datacube.py +++ b/openeo_driver/datacube.py @@ -1,26 +1,26 @@ import abc import inspect +import io import logging import zipfile from pathlib import Path -from typing import List, Union, Optional, Dict, Any, Tuple, Sequence -import io +from typing import Any, Dict, List, Optional, Sequence, Tuple, Union import geopandas as gpd import numpy +import openeo.udf import pandas import pyproj +import requests import shapely.geometry import shapely.geometry.base import shapely.ops import xarray -from pyproj import CRS -import requests - from openeo.metadata import CollectionMetadata from openeo.util import ensure_dir, str_truncate -import openeo.udf -from openeo_driver.datastructs import SarBackscatterArgs, ResolutionMergeArgs, StacAsset +from pyproj import CRS + +from openeo_driver.datastructs import ResolutionMergeArgs, SarBackscatterArgs, StacAsset from openeo_driver.errors import FeatureUnsupportedException, InternalException from openeo_driver.util.geometry import GeometryBufferer, validate_geojson_coordinates from openeo_driver.util.ioformats import IOFORMATS diff --git a/openeo_driver/processes.py b/openeo_driver/processes.py index e01f0006..e77d8211 100644 --- a/openeo_driver/processes.py +++ b/openeo_driver/processes.py @@ -3,16 +3,16 @@ import warnings from collections import namedtuple from pathlib import Path -from typing import Callable, Dict, List, Tuple, Optional, Any, Union, Collection +from typing import Any, Callable, Collection, Dict, List, Optional, Tuple, Union from openeo_driver.errors import ( - ProcessUnsupportedException, - ProcessParameterRequiredException, ProcessParameterInvalidException, + ProcessParameterRequiredException, + ProcessUnsupportedException, ) from openeo_driver.specs import SPECS_ROOT from openeo_driver.util.geometry import validate_geojson_basic -from openeo_driver.utils import read_json, EvalEnv +from openeo_driver.utils import EvalEnv, read_json class ProcessParameter: diff --git a/openeo_driver/testing.py b/openeo_driver/testing.py index 68f6bf7f..24d18d66 100644 --- a/openeo_driver/testing.py +++ b/openeo_driver/testing.py @@ -11,24 +11,21 @@ import re import urllib.request from pathlib import Path -from typing import Any, Callable, Dict, Optional, Pattern, Tuple, Union, Collection +from typing import Any, Callable, Collection, Dict, Optional, Pattern, Tuple, Union from unittest import mock +import openeo +import openeo.processes import pytest import shapely.geometry.base import shapely.wkt from flask import Response from flask.testing import FlaskClient +from openeo.capabilities import ComparableVersion from werkzeug.datastructures import Headers -import openeo -import openeo.processes -from openeo.capabilities import ComparableVersion from openeo_driver.users.auth import HttpAuthHandler -from openeo_driver.util.geometry import ( - as_geojson_feature, - as_geojson_feature_collection, -) +from openeo_driver.util.geometry import as_geojson_feature, as_geojson_feature_collection from openeo_driver.utils import generate_unique_id _log = logging.getLogger(__name__) @@ -587,6 +584,7 @@ def __repr__(self): msg += "\n" + "\n".join(f" # {i}" for i in self.actual_info) return msg + def caplog_with_custom_formatter(caplog: pytest.LogCaptureFixture, format: Union[str, logging.Formatter]): """ Context manager to set a custom formatter on the caplog fixture. diff --git a/openeo_driver/util/geometry.py b/openeo_driver/util/geometry.py index 8feab9fe..167d3adb 100644 --- a/openeo_driver/util/geometry.py +++ b/openeo_driver/util/geometry.py @@ -3,7 +3,7 @@ import logging import re from pathlib import Path -from typing import Union, Tuple, Optional, List, Mapping, Sequence, Any, Collection +from typing import Any, Collection, List, Mapping, Optional, Sequence, Tuple, Union import pyproj import shapely.geometry diff --git a/tests/test_delayed_vector.py b/tests/test_delayed_vector.py index b568d060..bb77db94 100644 --- a/tests/test_delayed_vector.py +++ b/tests/test_delayed_vector.py @@ -1,11 +1,12 @@ import re import pytest +from pyproj import CRS from openeo_driver.delayed_vector import DelayedVector from openeo_driver.errors import OpenEOApiException + from .data import get_path -from pyproj import CRS def test_feature_collection_bounds(): diff --git a/tests/test_testing.py b/tests/test_testing.py index efd8ca27..eab3cead 100644 --- a/tests/test_testing.py +++ b/tests/test_testing.py @@ -1,21 +1,22 @@ import logging import re import subprocess - -import numpy import sys import textwrap import urllib.error import urllib.request import flask +import numpy import pytest import requests from openeo_driver.testing import ( ApiTester, + ApproxGeoJSONByBounds, DictSubSet, IgnoreOrder, + IsNan, ListSubSet, RegexMatcher, UrllibMocker, @@ -23,8 +24,6 @@ caplog_with_custom_formatter, ephemeral_fileserver, preprocess_check_and_replace, - ApproxGeoJSONByBounds, - IsNan, ) diff --git a/tests/test_vectorcube.py b/tests/test_vectorcube.py index 7eb33643..b0029ced 100644 --- a/tests/test_vectorcube.py +++ b/tests/test_vectorcube.py @@ -6,11 +6,11 @@ import pyproj import pytest import xarray -from shapely.geometry import Polygon, MultiPolygon, Point +from shapely.geometry import MultiPolygon, Point, Polygon -from openeo_driver.errors import OpenEOApiException from openeo_driver.datacube import DriverVectorCube -from openeo_driver.testing import DictSubSet, ApproxGeometry, IsNan +from openeo_driver.errors import OpenEOApiException +from openeo_driver.testing import ApproxGeometry, DictSubSet, IsNan from openeo_driver.util.geometry import as_geojson_feature_collection from openeo_driver.utils import EvalEnv diff --git a/tests/test_views_execute.py b/tests/test_views_execute.py index 26372010..a43f4580 100644 --- a/tests/test_views_execute.py +++ b/tests/test_views_execute.py @@ -27,13 +27,13 @@ TEST_USER, TEST_USER_BEARER_TOKEN, ApiTester, + ApproxGeoJSONByBounds, DictSubSet, RegexMatcher, ephemeral_fileserver, generate_unique_test_process_id, preprocess_check_and_replace, preprocess_regex_check_and_replace, - ApproxGeoJSONByBounds, ) from openeo_driver.util.geometry import as_geojson_feature, as_geojson_feature_collection from openeo_driver.util.ioformats import IOFORMATS diff --git a/tests/util/test_geometry.py b/tests/util/test_geometry.py index 607fb64e..fc96d0c3 100644 --- a/tests/util/test_geometry.py +++ b/tests/util/test_geometry.py @@ -1,7 +1,6 @@ import contextlib -from typing import Union, List - import math +from typing import List, Union import pyproj import pytest @@ -12,20 +11,19 @@ from shapely.geos import WKTWriter from openeo_driver.util.geometry import ( - geojson_to_multipolygon, - reproject_bounding_box, - spatial_extent_union, + BoundingBox, + BoundingBoxException, + CrsRequired, GeometryBufferer, as_geojson_feature, as_geojson_feature_collection, + geojson_to_multipolygon, + reproject_bounding_box, reproject_geometry, - BoundingBox, - BoundingBoxException, - CrsRequired, + spatial_extent_union, validate_geojson_basic, ) - from ..data import get_path EARTH_CIRCUMFERENCE_KM = 40075.017