From 3cb7d958f06cb56bcdd660e7f08c0098ab182cdc Mon Sep 17 00:00:00 2001 From: arnasbr Date: Tue, 30 Apr 2024 14:50:32 +0300 Subject: [PATCH] Isort fixes --- benchmarks/common.py | 2 +- benchmarks/time_filter.py | 2 +- benchmarks/time_filter_fast.py | 2 +- benchmarks/time_map.py | 2 +- tests/distance_map_test.py | 3 +- tests/geocoding_test.py | 1 + tests/postcodes_test.py | 3 +- tests/routes_test.py | 4 +- tests/supported_locations.py | 2 +- tests/time_filter_proto_test.py | 6 +- tests/time_filter_test.py | 3 +- tests/time_map_test.py | 6 +- tests/wkt_parsing_test.py | 19 +-- tests/wkt_pretty_print_test.py | 11 +- traveltimepy/__init__.py | 36 ++---- traveltimepy/dto/common.py | 4 +- traveltimepy/dto/requests/distance_map.py | 17 +-- traveltimepy/dto/requests/postcodes.py | 18 +-- traveltimepy/dto/requests/postcodes_zones.py | 22 ++-- traveltimepy/dto/requests/request.py | 2 +- traveltimepy/dto/requests/routes.py | 16 +-- .../dto/requests/supported_locations.py | 3 +- traveltimepy/dto/requests/time_filter.py | 16 +-- traveltimepy/dto/requests/time_filter_fast.py | 4 +- traveltimepy/dto/requests/time_map.py | 18 +-- traveltimepy/dto/requests/time_map_geojson.py | 8 +- traveltimepy/dto/requests/time_map_wkt.py | 5 +- traveltimepy/dto/responses/time_filter.py | 2 +- .../dto/responses/time_filter_fast.py | 1 + traveltimepy/dto/responses/time_map_wkt.py | 5 +- traveltimepy/dto/transportation.py | 3 +- traveltimepy/http.py | 10 +- traveltimepy/itertools.py | 2 +- traveltimepy/mapper.py | 65 +++------- traveltimepy/proto_http.py | 16 +-- traveltimepy/sdk.py | 118 +++++++----------- traveltimepy/wkt/__init__.py | 19 +-- traveltimepy/wkt/constants.py | 10 +- traveltimepy/wkt/geometries.py | 2 +- traveltimepy/wkt/parsing.py | 37 ++---- 40 files changed, 179 insertions(+), 346 deletions(-) diff --git a/benchmarks/common.py b/benchmarks/common.py index 1dd2b9b1..8182dcb3 100644 --- a/benchmarks/common.py +++ b/benchmarks/common.py @@ -1,7 +1,7 @@ import random from typing import List -from traveltimepy import Location, Coordinates +from traveltimepy import Coordinates, Location def generate_float(value: float, radius: float) -> float: diff --git a/benchmarks/time_filter.py b/benchmarks/time_filter.py index cbdc3555..fd43e7ca 100644 --- a/benchmarks/time_filter.py +++ b/benchmarks/time_filter.py @@ -3,7 +3,7 @@ from datetime import datetime from benchmarks.common import generate_locations -from traveltimepy import TravelTimeSdk, Driving +from traveltimepy import Driving, TravelTimeSdk async def generate_matrix(size: int): diff --git a/benchmarks/time_filter_fast.py b/benchmarks/time_filter_fast.py index a0df824f..4eb4961d 100644 --- a/benchmarks/time_filter_fast.py +++ b/benchmarks/time_filter_fast.py @@ -2,7 +2,7 @@ import time from benchmarks.common import generate_locations -from traveltimepy import TravelTimeSdk, Transportation +from traveltimepy import Transportation, TravelTimeSdk async def generate_matrix(size: int): diff --git a/benchmarks/time_map.py b/benchmarks/time_map.py index e4b8ca4c..2f636d3b 100644 --- a/benchmarks/time_map.py +++ b/benchmarks/time_map.py @@ -3,7 +3,7 @@ from datetime import datetime from benchmarks.common import generate_coordinates -from traveltimepy import TravelTimeSdk, Driving +from traveltimepy import Driving, TravelTimeSdk async def generate_isochrones(size: int): diff --git a/tests/distance_map_test.py b/tests/distance_map_test.py index 2e0c381b..22bac168 100644 --- a/tests/distance_map_test.py +++ b/tests/distance_map_test.py @@ -1,6 +1,7 @@ -import pytest from datetime import datetime +import pytest + from traveltimepy import Coordinates, Driving, LevelOfDetail, TravelTimeSdk diff --git a/tests/geocoding_test.py b/tests/geocoding_test.py index 2b67df7b..f72e996d 100644 --- a/tests/geocoding_test.py +++ b/tests/geocoding_test.py @@ -1,4 +1,5 @@ import pytest + from traveltimepy import TravelTimeSdk diff --git a/tests/postcodes_test.py b/tests/postcodes_test.py index 4524da46..ad2a3093 100644 --- a/tests/postcodes_test.py +++ b/tests/postcodes_test.py @@ -1,6 +1,7 @@ -import pytest from datetime import datetime +import pytest + from traveltimepy import Coordinates, PublicTransport, TravelTimeSdk diff --git a/tests/routes_test.py b/tests/routes_test.py index e58a9c5d..e5c7d133 100644 --- a/tests/routes_test.py +++ b/tests/routes_test.py @@ -1,9 +1,9 @@ +from datetime import datetime from typing import List import pytest -from datetime import datetime -from traveltimepy import PublicTransport, Driving, Location, Coordinates +from traveltimepy import Coordinates, Driving, Location, PublicTransport from traveltimepy.dto.common import SnapPenalty from traveltimepy.sdk import TravelTimeSdk diff --git a/tests/supported_locations.py b/tests/supported_locations.py index 33ac8be4..1a47ea48 100644 --- a/tests/supported_locations.py +++ b/tests/supported_locations.py @@ -1,6 +1,6 @@ import pytest -from traveltimepy import Location, Coordinates, TravelTimeSdk +from traveltimepy import Coordinates, Location, TravelTimeSdk @pytest.mark.asyncio diff --git a/tests/time_filter_proto_test.py b/tests/time_filter_proto_test.py index 2829723c..5b70ef55 100644 --- a/tests/time_filter_proto_test.py +++ b/tests/time_filter_proto_test.py @@ -2,10 +2,8 @@ from traveltimepy import Coordinates from traveltimepy.dto.common import PropertyProto -from traveltimepy.dto.requests.time_filter_proto import ( - ProtoTransportation, - ProtoCountry, -) +from traveltimepy.dto.requests.time_filter_proto import (ProtoCountry, + ProtoTransportation) from traveltimepy.sdk import TravelTimeSdk diff --git a/tests/time_filter_test.py b/tests/time_filter_test.py index 1b3d2613..ed1dd438 100644 --- a/tests/time_filter_test.py +++ b/tests/time_filter_test.py @@ -1,6 +1,7 @@ -import pytest from datetime import datetime +import pytest + from traveltimepy import PublicTransport, TravelTimeSdk diff --git a/tests/time_map_test.py b/tests/time_map_test.py index 479930fa..fdafaa47 100644 --- a/tests/time_map_test.py +++ b/tests/time_map_test.py @@ -1,7 +1,9 @@ -import pytest from datetime import datetime -from traveltimepy import Coordinates, Driving, LevelOfDetail, Range, TravelTimeSdk +import pytest + +from traveltimepy import (Coordinates, Driving, LevelOfDetail, Range, + TravelTimeSdk) @pytest.mark.asyncio diff --git a/tests/wkt_parsing_test.py b/tests/wkt_parsing_test.py index 7ccd9ea9..2da0c181 100644 --- a/tests/wkt_parsing_test.py +++ b/tests/wkt_parsing_test.py @@ -1,20 +1,11 @@ import pytest # noqa from traveltimepy import Coordinates -from traveltimepy.wkt import ( - parse_wkt, - PointModel, - LineStringModel, - PolygonModel, - MultiPointModel, - MultiLineStringModel, - MultiPolygonModel, -) -from traveltimepy.wkt.error import ( - InvalidWKTStringError, - NullGeometryError, - InvalidGeometryTypeError, -) +from traveltimepy.wkt import (LineStringModel, MultiLineStringModel, + MultiPointModel, MultiPolygonModel, PointModel, + PolygonModel, parse_wkt) +from traveltimepy.wkt.error import (InvalidGeometryTypeError, + InvalidWKTStringError, NullGeometryError) point_wkt = "POINT (0 0)" line_wkt = "LINESTRING(0 0, 1 1, 2 2)" diff --git a/tests/wkt_pretty_print_test.py b/tests/wkt_pretty_print_test.py index aa3feab9..b974765c 100644 --- a/tests/wkt_pretty_print_test.py +++ b/tests/wkt_pretty_print_test.py @@ -1,14 +1,9 @@ import pytest # noqa from traveltimepy import Coordinates -from traveltimepy.wkt import ( - PointModel, - LineStringModel, - PolygonModel, - MultiPointModel, - MultiLineStringModel, - MultiPolygonModel, -) +from traveltimepy.wkt import (LineStringModel, MultiLineStringModel, + MultiPointModel, MultiPolygonModel, PointModel, + PolygonModel) # Updated mock data for LineStringModel with two distinct points mock_point1 = PointModel(coordinates=Coordinates(lat=10, lng=20)) diff --git a/traveltimepy/__init__.py b/traveltimepy/__init__.py index 8eef3353..33b77d16 100644 --- a/traveltimepy/__init__.py +++ b/traveltimepy/__init__.py @@ -1,32 +1,16 @@ """Python sdk for working with traveltime api""" -from traveltimepy.dto.transportation import ( - PublicTransport, - Driving, - Ferry, - Walking, - Cycling, - DrivingTrain, - CyclingPublicTransport, -) -from traveltimepy.dto.requests.time_filter_proto import ( - ProtoTransportation, - ProtoCountry, -) -from traveltimepy.dto.common import ( - Coordinates, - Location, - Property, - PropertyProto, - FullRange, - Range, - Rectangle, - LevelOfDetail, -) - -from traveltimepy.sdk import TravelTimeSdk -from traveltimepy.dto.requests.time_filter_fast import Transportation +from traveltimepy.dto.common import (Coordinates, FullRange, LevelOfDetail, + Location, Property, PropertyProto, Range, + Rectangle) from traveltimepy.dto.requests.postcodes_zones import ZonesProperty +from traveltimepy.dto.requests.time_filter_fast import Transportation +from traveltimepy.dto.requests.time_filter_proto import (ProtoCountry, + ProtoTransportation) +from traveltimepy.dto.transportation import (Cycling, CyclingPublicTransport, + Driving, DrivingTrain, Ferry, + PublicTransport, Walking) +from traveltimepy.sdk import TravelTimeSdk from traveltimepy.version import __version__ __all__ = [ diff --git a/traveltimepy/dto/common.py b/traveltimepy/dto/common.py index 7c417074..62b3642e 100644 --- a/traveltimepy/dto/common.py +++ b/traveltimepy/dto/common.py @@ -1,10 +1,10 @@ from datetime import datetime, time from enum import Enum -from typing import List, Union, Optional +from typing import List, Optional, Union from pydantic import field_validator -from typing_extensions import Literal from pydantic.main import BaseModel +from typing_extensions import Literal class Coordinates(BaseModel): diff --git a/traveltimepy/dto/requests/distance_map.py b/traveltimepy/dto/requests/distance_map.py index c4448396..d88d937c 100644 --- a/traveltimepy/dto/requests/distance_map.py +++ b/traveltimepy/dto/requests/distance_map.py @@ -1,25 +1,16 @@ import typing from datetime import datetime - from typing import List, Optional from pydantic.main import BaseModel -from traveltimepy import ( - Coordinates, - PublicTransport, - Driving, - Ferry, - Walking, - Cycling, - DrivingTrain, - CyclingPublicTransport, - LevelOfDetail, -) +from traveltimepy import (Coordinates, Cycling, CyclingPublicTransport, + Driving, DrivingTrain, Ferry, LevelOfDetail, + PublicTransport, Walking) from traveltimepy.dto.common import SnapPenalty from traveltimepy.dto.requests.request import TravelTimeRequest from traveltimepy.dto.responses.time_map import TimeMapResponse -from traveltimepy.itertools import split, flatten +from traveltimepy.itertools import flatten, split class DepartureSearch(BaseModel): diff --git a/traveltimepy/dto/requests/postcodes.py b/traveltimepy/dto/requests/postcodes.py index cead7dcb..d9cc3725 100644 --- a/traveltimepy/dto/requests/postcodes.py +++ b/traveltimepy/dto/requests/postcodes.py @@ -1,21 +1,15 @@ from datetime import datetime -from typing import List, Union, Optional +from typing import List, Optional, Union from pydantic import BaseModel -from traveltimepy.dto.common import Coordinates, Property, FullRange +from traveltimepy.dto.common import Coordinates, FullRange, Property from traveltimepy.dto.requests.request import TravelTimeRequest from traveltimepy.dto.responses.postcodes import PostcodesResponse -from traveltimepy.itertools import split, flatten -from traveltimepy.dto.transportation import ( - PublicTransport, - Driving, - Ferry, - Walking, - Cycling, - DrivingTrain, - CyclingPublicTransport, -) +from traveltimepy.dto.transportation import (Cycling, CyclingPublicTransport, + Driving, DrivingTrain, Ferry, + PublicTransport, Walking) +from traveltimepy.itertools import flatten, split class ArrivalSearch(BaseModel): diff --git a/traveltimepy/dto/requests/postcodes_zones.py b/traveltimepy/dto/requests/postcodes_zones.py index 6d77514f..0260bcf1 100644 --- a/traveltimepy/dto/requests/postcodes_zones.py +++ b/traveltimepy/dto/requests/postcodes_zones.py @@ -1,25 +1,17 @@ from datetime import datetime from enum import Enum -from typing import List, Union, Optional +from typing import List, Optional, Union from pydantic import BaseModel from traveltimepy.dto.common import Coordinates, FullRange from traveltimepy.dto.requests.request import TravelTimeRequest -from traveltimepy.dto.responses.zones import ( - PostcodesDistrictsResponse, - PostcodesSectorsResponse, -) -from traveltimepy.itertools import split, flatten -from traveltimepy.dto.transportation import ( - PublicTransport, - Driving, - Ferry, - Walking, - Cycling, - DrivingTrain, - CyclingPublicTransport, -) +from traveltimepy.dto.responses.zones import (PostcodesDistrictsResponse, + PostcodesSectorsResponse) +from traveltimepy.dto.transportation import (Cycling, CyclingPublicTransport, + Driving, DrivingTrain, Ferry, + PublicTransport, Walking) +from traveltimepy.itertools import flatten, split class ZonesProperty(str, Enum): diff --git a/traveltimepy/dto/requests/request.py b/traveltimepy/dto/requests/request.py index 4b354deb..9c3d5552 100644 --- a/traveltimepy/dto/requests/request.py +++ b/traveltimepy/dto/requests/request.py @@ -1,7 +1,7 @@ from __future__ import annotations from abc import ABC, abstractmethod -from typing import List, TypeVar, Generic +from typing import Generic, List, TypeVar from pydantic import BaseModel diff --git a/traveltimepy/dto/requests/routes.py b/traveltimepy/dto/requests/routes.py index d315efde..88a6cc82 100644 --- a/traveltimepy/dto/requests/routes.py +++ b/traveltimepy/dto/requests/routes.py @@ -3,19 +3,13 @@ from pydantic.main import BaseModel -from traveltimepy.dto.common import Location, Property, FullRange, SnapPenalty -from traveltimepy.dto.transportation import ( - PublicTransport, - Driving, - Ferry, - Walking, - Cycling, - DrivingTrain, - CyclingPublicTransport, -) +from traveltimepy.dto.common import FullRange, Location, Property, SnapPenalty from traveltimepy.dto.requests.request import TravelTimeRequest from traveltimepy.dto.responses.routes import RoutesResponse -from traveltimepy.itertools import split, flatten +from traveltimepy.dto.transportation import (Cycling, CyclingPublicTransport, + Driving, DrivingTrain, Ferry, + PublicTransport, Walking) +from traveltimepy.itertools import flatten, split class ArrivalSearch(BaseModel): diff --git a/traveltimepy/dto/requests/supported_locations.py b/traveltimepy/dto/requests/supported_locations.py index 61a1684a..ac68c09e 100644 --- a/traveltimepy/dto/requests/supported_locations.py +++ b/traveltimepy/dto/requests/supported_locations.py @@ -2,7 +2,8 @@ from traveltimepy.dto.common import Location from traveltimepy.dto.requests.request import TravelTimeRequest -from traveltimepy.dto.responses.supported_locations import SupportedLocationsResponse +from traveltimepy.dto.responses.supported_locations import \ + SupportedLocationsResponse from traveltimepy.itertools import flatten diff --git a/traveltimepy/dto/requests/time_filter.py b/traveltimepy/dto/requests/time_filter.py index dc688b42..80591d3f 100644 --- a/traveltimepy/dto/requests/time_filter.py +++ b/traveltimepy/dto/requests/time_filter.py @@ -3,19 +3,13 @@ from pydantic.main import BaseModel -from traveltimepy.dto.common import Location, FullRange, Property, SnapPenalty +from traveltimepy.dto.common import FullRange, Location, Property, SnapPenalty from traveltimepy.dto.requests.request import TravelTimeRequest from traveltimepy.dto.responses.time_filter import TimeFilterResponse -from traveltimepy.itertools import split, flatten -from traveltimepy.dto.transportation import ( - PublicTransport, - Driving, - Ferry, - Walking, - Cycling, - DrivingTrain, - CyclingPublicTransport, -) +from traveltimepy.dto.transportation import (Cycling, CyclingPublicTransport, + Driving, DrivingTrain, Ferry, + PublicTransport, Walking) +from traveltimepy.itertools import flatten, split class ArrivalSearch(BaseModel): diff --git a/traveltimepy/dto/requests/time_filter_fast.py b/traveltimepy/dto/requests/time_filter_fast.py index 2e495936..82e0a664 100644 --- a/traveltimepy/dto/requests/time_filter_fast.py +++ b/traveltimepy/dto/requests/time_filter_fast.py @@ -1,12 +1,12 @@ from typing import List, Optional -from typing_extensions import Literal from pydantic import BaseModel +from typing_extensions import Literal from traveltimepy.dto.common import Location, Property, SnapPenalty from traveltimepy.dto.requests.request import TravelTimeRequest from traveltimepy.dto.responses.time_filter_fast import TimeFilterFastResponse -from traveltimepy.itertools import split, flatten +from traveltimepy.itertools import flatten, split class Transportation(BaseModel): diff --git a/traveltimepy/dto/requests/time_map.py b/traveltimepy/dto/requests/time_map.py index d2334cca..2a708238 100644 --- a/traveltimepy/dto/requests/time_map.py +++ b/traveltimepy/dto/requests/time_map.py @@ -1,26 +1,16 @@ import typing from datetime import datetime - from typing import List, Optional from pydantic.main import BaseModel -from traveltimepy import ( - Coordinates, - Range, - PublicTransport, - Driving, - Ferry, - Walking, - Cycling, - DrivingTrain, - CyclingPublicTransport, - LevelOfDetail, -) +from traveltimepy import (Coordinates, Cycling, CyclingPublicTransport, + Driving, DrivingTrain, Ferry, LevelOfDetail, + PublicTransport, Range, Walking) from traveltimepy.dto.common import SnapPenalty from traveltimepy.dto.requests.request import TravelTimeRequest from traveltimepy.dto.responses.time_map import TimeMapResponse -from traveltimepy.itertools import split, flatten +from traveltimepy.itertools import flatten, split class DepartureSearch(BaseModel): diff --git a/traveltimepy/dto/requests/time_map_geojson.py b/traveltimepy/dto/requests/time_map_geojson.py index 58305146..0931f551 100644 --- a/traveltimepy/dto/requests/time_map_geojson.py +++ b/traveltimepy/dto/requests/time_map_geojson.py @@ -1,12 +1,10 @@ from typing import List from geojson_pydantic import FeatureCollection + from traveltimepy.dto.requests.request import TravelTimeRequest -from traveltimepy.dto.requests.time_map import ( - DepartureSearch, - ArrivalSearch, -) -from traveltimepy.itertools import split, flatten +from traveltimepy.dto.requests.time_map import ArrivalSearch, DepartureSearch +from traveltimepy.itertools import flatten, split class TimeMapRequestGeojson(TravelTimeRequest[FeatureCollection]): diff --git a/traveltimepy/dto/requests/time_map_wkt.py b/traveltimepy/dto/requests/time_map_wkt.py index aaf480fc..5263f1b9 100644 --- a/traveltimepy/dto/requests/time_map_wkt.py +++ b/traveltimepy/dto/requests/time_map_wkt.py @@ -1,8 +1,9 @@ from typing import List + from traveltimepy.dto.requests.request import TravelTimeRequest -from traveltimepy.dto.requests.time_map import DepartureSearch, ArrivalSearch +from traveltimepy.dto.requests.time_map import ArrivalSearch, DepartureSearch from traveltimepy.dto.responses.time_map_wkt import TimeMapWKTResponse -from traveltimepy.itertools import split, flatten +from traveltimepy.itertools import flatten, split class TimeMapWKTRequest(TravelTimeRequest[TimeMapWKTResponse]): diff --git a/traveltimepy/dto/responses/time_filter.py b/traveltimepy/dto/responses/time_filter.py index 061b98f2..c467b262 100644 --- a/traveltimepy/dto/responses/time_filter.py +++ b/traveltimepy/dto/responses/time_filter.py @@ -2,7 +2,7 @@ from pydantic.main import BaseModel -from traveltimepy.dto.common import Route, Fares +from traveltimepy.dto.common import Fares, Route class DistanceBreakdown(BaseModel): diff --git a/traveltimepy/dto/responses/time_filter_fast.py b/traveltimepy/dto/responses/time_filter_fast.py index b9876964..47910ed4 100644 --- a/traveltimepy/dto/responses/time_filter_fast.py +++ b/traveltimepy/dto/responses/time_filter_fast.py @@ -1,4 +1,5 @@ from typing import List, Optional + from pydantic import BaseModel diff --git a/traveltimepy/dto/responses/time_map_wkt.py b/traveltimepy/dto/responses/time_map_wkt.py index c7c0914d..0a76965f 100644 --- a/traveltimepy/dto/responses/time_map_wkt.py +++ b/traveltimepy/dto/responses/time_map_wkt.py @@ -1,5 +1,6 @@ -from typing import Generic, List, Union, Dict, Any, TypeVar, Optional -from pydantic import field_validator, BaseModel, Field +from typing import Any, Dict, Generic, List, Optional, TypeVar, Union + +from pydantic import BaseModel, Field, field_validator from traveltimepy.wkt import WKTObject, parse_wkt from traveltimepy.wkt.helper import print_indented diff --git a/traveltimepy/dto/transportation.py b/traveltimepy/dto/transportation.py index c7399360..1284595c 100644 --- a/traveltimepy/dto/transportation.py +++ b/traveltimepy/dto/transportation.py @@ -1,8 +1,7 @@ from typing import Optional -from typing_extensions import Literal - from pydantic.main import BaseModel +from typing_extensions import Literal class MaxChanges(BaseModel): diff --git a/traveltimepy/http.py b/traveltimepy/http.py index 19dca1b1..702ca7d3 100644 --- a/traveltimepy/http.py +++ b/traveltimepy/http.py @@ -1,16 +1,16 @@ import asyncio import json from dataclasses import dataclass -from typing import TypeVar, Type, Dict, Optional +from typing import Dict, Optional, Type, TypeVar -from aiohttp import ClientSession, ClientResponse, TCPConnector, ClientTimeout +from aiohttp import ClientResponse, ClientSession, ClientTimeout, TCPConnector +from aiohttp_retry import ExponentialRetry, RetryClient +from aiolimiter import AsyncLimiter from pydantic import BaseModel -from traveltimepy.dto.requests.request import TravelTimeRequest +from traveltimepy.dto.requests.request import TravelTimeRequest from traveltimepy.dto.responses.error import ResponseError from traveltimepy.errors import ApiError -from aiohttp_retry import RetryClient, ExponentialRetry -from aiolimiter import AsyncLimiter T = TypeVar("T", bound=BaseModel) DEFAULT_SPLIT_SIZE = 10 diff --git a/traveltimepy/itertools.py b/traveltimepy/itertools.py index 9d2fb532..1a145296 100644 --- a/traveltimepy/itertools.py +++ b/traveltimepy/itertools.py @@ -1,5 +1,5 @@ import itertools -from typing import List, TypeVar, Tuple, Optional +from typing import List, Optional, Tuple, TypeVar T = TypeVar("T") R = TypeVar("R") diff --git a/traveltimepy/mapper.py b/traveltimepy/mapper.py index 166c77f6..62e53ffe 100644 --- a/traveltimepy/mapper.py +++ b/traveltimepy/mapper.py @@ -1,57 +1,30 @@ import math -from typing import Dict, Union, List, Optional +from typing import Dict, List, Optional, Union -from traveltimepy.dto.requests.distance_map import DistanceMapRequest -from traveltimepy.dto.requests.time_map_geojson import TimeMapRequestGeojson -from traveltimepy.dto.requests.time_map_wkt import TimeMapWKTRequest -from traveltimepy.errors import ApiError from traveltimepy import TimeFilterFastRequest_pb2 - -from traveltimepy.dto.common import ( - Location, - Coordinates, - FullRange, - Property, - Range, - LevelOfDetail, - PropertyProto, - TimeInfo, - ArrivalTime, - DepartureTime, - SnapPenalty, -) -from traveltimepy.dto.transportation import ( - PublicTransport, - Driving, - Ferry, - Walking, - Cycling, - DrivingTrain, - CyclingPublicTransport, -) -from traveltimepy.dto.requests.time_filter_fast import Transportation -from traveltimepy.dto.requests.postcodes_zones import ZonesProperty - +from traveltimepy.dto.common import (ArrivalTime, Coordinates, DepartureTime, + FullRange, LevelOfDetail, Location, + Property, PropertyProto, Range, + SnapPenalty, TimeInfo) +from traveltimepy.dto.requests import (distance_map, postcodes, + postcodes_zones, routes, time_filter, + time_filter_fast, time_map) +from traveltimepy.dto.requests.distance_map import DistanceMapRequest from traveltimepy.dto.requests.postcodes import PostcodesRequest +from traveltimepy.dto.requests.postcodes_zones import ( + PostcodesDistrictsRequest, PostcodesSectorsRequest, ZonesProperty) from traveltimepy.dto.requests.routes import RoutesRequest from traveltimepy.dto.requests.time_filter import TimeFilterRequest -from traveltimepy.dto.requests.time_filter_fast import TimeFilterFastRequest +from traveltimepy.dto.requests.time_filter_fast import (TimeFilterFastRequest, + Transportation) from traveltimepy.dto.requests.time_filter_proto import ProtoTransportation -from traveltimepy.dto.requests.postcodes_zones import ( - PostcodesDistrictsRequest, - PostcodesSectorsRequest, -) from traveltimepy.dto.requests.time_map import TimeMapRequest - -from traveltimepy.dto.requests import ( - distance_map, - time_filter, - time_filter_fast, - postcodes, - postcodes_zones, - routes, - time_map, -) +from traveltimepy.dto.requests.time_map_geojson import TimeMapRequestGeojson +from traveltimepy.dto.requests.time_map_wkt import TimeMapWKTRequest +from traveltimepy.dto.transportation import (Cycling, CyclingPublicTransport, + Driving, DrivingTrain, Ferry, + PublicTransport, Walking) +from traveltimepy.errors import ApiError def create_time_filter( diff --git a/traveltimepy/proto_http.py b/traveltimepy/proto_http.py index 2eec5ac2..dcd3debb 100644 --- a/traveltimepy/proto_http.py +++ b/traveltimepy/proto_http.py @@ -1,17 +1,13 @@ from typing import Dict -from aiohttp import ( - ClientSession, - ClientResponse, - BasicAuth, - TCPConnector, - ClientTimeout, -) +from aiohttp import (BasicAuth, ClientResponse, ClientSession, ClientTimeout, + TCPConnector) -from traveltimepy.TimeFilterFastResponse_pb2 import TimeFilterFastResponse -from traveltimepy.TimeFilterFastRequest_pb2 import TimeFilterFastRequest -from traveltimepy.dto.responses.time_filter_proto import TimeFilterProtoResponse +from traveltimepy.dto.responses.time_filter_proto import \ + TimeFilterProtoResponse from traveltimepy.errors import ApiError +from traveltimepy.TimeFilterFastRequest_pb2 import TimeFilterFastRequest +from traveltimepy.TimeFilterFastResponse_pb2 import TimeFilterFastResponse async def send_proto_async( diff --git a/traveltimepy/sdk.py b/traveltimepy/sdk.py index 07f1a8ad..5fa033df 100644 --- a/traveltimepy/sdk.py +++ b/traveltimepy/sdk.py @@ -1,86 +1,52 @@ from datetime import datetime -from typing import List, Optional, Dict, Union - -from traveltimepy.dto.common import ( - Location, - Coordinates, - Rectangle, - Property, - FullRange, - Range, - LevelOfDetail, - PropertyProto, - DepartureTime, - ArrivalTime, - SnapPenalty, -) -from traveltimepy.dto.responses.time_map_wkt import ( - TimeMapWKTResponse, -) -from traveltimepy.dto.responses.time_filter_proto import TimeFilterProtoResponse -from traveltimepy.dto.transportation import ( - PublicTransport, - Driving, - Ferry, - Walking, - Cycling, - DrivingTrain, - CyclingPublicTransport, -) -from traveltimepy.dto.requests.postcodes_zones import ZonesProperty -from traveltimepy.dto.requests.time_filter_proto import ( - ProtoCountry, - ProtoTransportation, -) -from traveltimepy.dto.requests.time_filter_fast import Transportation -from traveltimepy.errors import ApiError +from typing import Dict, List, Optional, Union -from traveltimepy.version import __version__ -from traveltimepy.accept_type import AcceptType -from traveltimepy.itertools import join_opt -from traveltimepy.dto.requests.supported_locations import SupportedLocationsRequest +from geojson_pydantic import FeatureCollection -from traveltimepy.dto.responses.map_info import MapInfoResponse, Map -from traveltimepy.dto.responses.postcodes import PostcodesResponse, PostcodesResult +from traveltimepy.accept_type import AcceptType +from traveltimepy.dto.common import (ArrivalTime, Coordinates, DepartureTime, + FullRange, LevelOfDetail, Location, + Property, PropertyProto, Range, Rectangle, + SnapPenalty) +from traveltimepy.dto.requests.postcodes_zones import ZonesProperty +from traveltimepy.dto.requests.supported_locations import \ + SupportedLocationsRequest +from traveltimepy.dto.requests.time_filter_fast import Transportation +from traveltimepy.dto.requests.time_filter_proto import (ProtoCountry, + ProtoTransportation) +from traveltimepy.dto.responses.map_info import Map, MapInfoResponse +from traveltimepy.dto.responses.postcodes import (PostcodesResponse, + PostcodesResult) from traveltimepy.dto.responses.routes import RoutesResponse, RoutesResult -from traveltimepy.dto.responses.supported_locations import SupportedLocationsResponse -from traveltimepy.dto.responses.time_filter import TimeFilterResponse, TimeFilterResult +from traveltimepy.dto.responses.supported_locations import \ + SupportedLocationsResponse +from traveltimepy.dto.responses.time_filter import (TimeFilterResponse, + TimeFilterResult) from traveltimepy.dto.responses.time_filter_fast import ( - TimeFilterFastResponse, - TimeFilterFastResult, -) + TimeFilterFastResponse, TimeFilterFastResult) +from traveltimepy.dto.responses.time_filter_proto import \ + TimeFilterProtoResponse from traveltimepy.dto.responses.time_map import TimeMapResponse, TimeMapResult -from traveltimepy.dto.responses.zones import ( - PostcodesDistrictsResponse, - PostcodesSectorsResponse, - PostcodesDistrictsResult, - PostcodesSectorsResult, -) - -from traveltimepy.mapper import ( - create_distance_map, - create_time_filter, - create_time_filter_fast, - create_postcodes, - create_districts, - create_sectors, - create_routes, - create_proto_request, - create_time_map, - create_intersection, - create_union, - create_time_map_geojson, - create_time_map_wkt, -) - +from traveltimepy.dto.responses.time_map_wkt import TimeMapWKTResponse +from traveltimepy.dto.responses.zones import (PostcodesDistrictsResponse, + PostcodesDistrictsResult, + PostcodesSectorsResponse, + PostcodesSectorsResult) +from traveltimepy.dto.transportation import (Cycling, CyclingPublicTransport, + Driving, DrivingTrain, Ferry, + PublicTransport, Walking) +from traveltimepy.errors import ApiError +from traveltimepy.http import SdkParams, send_get_async, send_post_async +from traveltimepy.itertools import join_opt +from traveltimepy.mapper import (create_distance_map, create_districts, + create_intersection, create_postcodes, + create_proto_request, create_routes, + create_sectors, create_time_filter, + create_time_filter_fast, create_time_map, + create_time_map_geojson, create_time_map_wkt, + create_union) from traveltimepy.proto_http import send_proto_async -from traveltimepy.http import ( - send_get_async, - send_post_async, - SdkParams, -) - -from geojson_pydantic import FeatureCollection +from traveltimepy.version import __version__ class TravelTimeSdk: diff --git a/traveltimepy/wkt/__init__.py b/traveltimepy/wkt/__init__.py index 4e9f202f..b9b75db8 100644 --- a/traveltimepy/wkt/__init__.py +++ b/traveltimepy/wkt/__init__.py @@ -1,19 +1,10 @@ """Module with WKT wrapper for shapely""" -from traveltimepy.wkt.parsing import ( - parse_wkt, -) - -from traveltimepy.wkt.geometries import ( - WKTObject, - PointModel, - LineStringModel, - PolygonModel, - MultiLineStringModel, - MultiPointModel, - MultiPolygonModel, - GeometryType, -) +from traveltimepy.wkt.geometries import (GeometryType, LineStringModel, + MultiLineStringModel, MultiPointModel, + MultiPolygonModel, PointModel, + PolygonModel, WKTObject) +from traveltimepy.wkt.parsing import parse_wkt __all__ = [ "WKTObject", diff --git a/traveltimepy/wkt/constants.py b/traveltimepy/wkt/constants.py index c159f7e2..2bba6939 100644 --- a/traveltimepy/wkt/constants.py +++ b/traveltimepy/wkt/constants.py @@ -1,11 +1,5 @@ -from shapely.geometry import ( - Point, - LineString, - Polygon, - MultiPoint, - MultiLineString, - MultiPolygon, -) +from shapely.geometry import (LineString, MultiLineString, MultiPoint, + MultiPolygon, Point, Polygon) SUPPORTED_GEOMETRY_TYPES = [ Point, diff --git a/traveltimepy/wkt/geometries.py b/traveltimepy/wkt/geometries.py index 5a31a4ea..59a35f34 100644 --- a/traveltimepy/wkt/geometries.py +++ b/traveltimepy/wkt/geometries.py @@ -2,7 +2,7 @@ from enum import Enum from typing import List -from pydantic import field_validator, BaseModel +from pydantic import BaseModel, field_validator from traveltimepy import Coordinates from traveltimepy.wkt.helper import print_indented diff --git a/traveltimepy/wkt/parsing.py b/traveltimepy/wkt/parsing.py index fcfb4082..f11b20ae 100644 --- a/traveltimepy/wkt/parsing.py +++ b/traveltimepy/wkt/parsing.py @@ -1,36 +1,19 @@ from functools import singledispatch from typing import Union -from shapely import wkt, GEOSException -from shapely.geometry import ( - Point, - LineString, - Polygon, - MultiPoint, - MultiLineString, - MultiPolygon, -) +from shapely import GEOSException, wkt +from shapely.geometry import (LineString, MultiLineString, MultiPoint, + MultiPolygon, Point, Polygon) from shapely.geometry.base import BaseGeometry from traveltimepy import Coordinates -from traveltimepy.wkt.geometries import ( - PointModel, - LineStringModel, - PolygonModel, - MultiPointModel, - MultiLineStringModel, - MultiPolygonModel, -) -from traveltimepy.wkt.constants import ( - SUPPORTED_GEOMETRY_TYPES, -) - -from traveltimepy.wkt.error import ( - InvalidWKTStringError, - NullGeometryError, - InvalidFunctionError, - InvalidGeometryTypeError, -) +from traveltimepy.wkt.constants import SUPPORTED_GEOMETRY_TYPES +from traveltimepy.wkt.error import (InvalidFunctionError, + InvalidGeometryTypeError, + InvalidWKTStringError, NullGeometryError) +from traveltimepy.wkt.geometries import (LineStringModel, MultiLineStringModel, + MultiPointModel, MultiPolygonModel, + PointModel, PolygonModel) def _check_empty(geometry):