From eac7cca263f2af56cc9b11fc61d5d5aecffd2adf Mon Sep 17 00:00:00 2001 From: Lucas Pedroza Date: Mon, 20 May 2024 15:27:51 +0200 Subject: [PATCH] Run optimize imports everywhere --- fauna/client/client.py | 15 +++++++-------- fauna/client/retryable.py | 3 +-- fauna/encoding/encoder.py | 3 ++- fauna/errors/__init__.py | 8 ++++---- fauna/http/http_client.py | 3 +-- fauna/http/httpx_client.py | 2 +- fauna/query/__init__.py | 2 +- fauna/query/template.py | 2 +- tests/integration/test_client.py | 6 +++--- .../integration/test_client_with_query_limits.py | 2 +- tests/integration/test_data_type_roundtrips.py | 1 - tests/integration/test_query.py | 4 ++-- tests/integration/test_stream.py | 7 ++++--- tests/unit/test_client.py | 5 ++--- tests/unit/test_encoding.py | 2 +- tests/unit/test_httpx_client.py | 1 - tests/unit/test_models.py | 2 +- tests/unit/test_retryable.py | 3 ++- 18 files changed, 34 insertions(+), 37 deletions(-) diff --git a/fauna/client/client.py b/fauna/client/client.py index a4a6ce42..fa90df3e 100644 --- a/fauna/client/client.py +++ b/fauna/client/client.py @@ -1,19 +1,18 @@ -from datetime import timedelta from dataclasses import dataclass -from typing import Any, Dict, Iterator, Mapping, Optional, List, Union -from contextlib import contextmanager +from datetime import timedelta +from typing import Any, Dict, Iterator, Mapping, Optional, Union import fauna +from fauna.client.headers import _DriverEnvironment, _Header, _Auth, Header from fauna.client.retryable import Retryable +from fauna.client.utils import _Environment, LastTxnTs +from fauna.encoding import FaunaEncoder, FaunaDecoder +from fauna.encoding import QuerySuccess, QueryTags, QueryStats from fauna.errors import FaunaError, ClientError, ProtocolError, \ - RetryableFaunaException, NetworkError -from fauna.client.headers import _DriverEnvironment, _Header, _Auth, Header + RetryableFaunaException, NetworkError from fauna.http.http_client import HTTPClient from fauna.query import Query, Page, fql from fauna.query.models import StreamToken -from fauna.client.utils import _Environment, LastTxnTs -from fauna.encoding import FaunaEncoder, FaunaDecoder -from fauna.encoding import QuerySuccess, ConstraintFailure, QueryTags, QueryStats DefaultHttpConnectTimeout = timedelta(seconds=5) DefaultHttpReadTimeout: Optional[timedelta] = None diff --git a/fauna/client/retryable.py b/fauna/client/retryable.py index e55ad309..c5d50fc5 100644 --- a/fauna/client/retryable.py +++ b/fauna/client/retryable.py @@ -4,8 +4,7 @@ from time import sleep from typing import Callable, Optional, TypeVar, Generic -from fauna.encoding import QuerySuccess -from fauna.errors import RetryableFaunaException, ClientError +from fauna.errors import RetryableFaunaException class RetryStrategy: diff --git a/fauna/encoding/encoder.py b/fauna/encoding/encoder.py index bac96e93..986b8a1d 100644 --- a/fauna/encoding/encoder.py +++ b/fauna/encoding/encoder.py @@ -2,7 +2,8 @@ from datetime import datetime, date from typing import Any, Optional, List, Union -from fauna.query.models import DocumentReference, Module, Document, NamedDocument, NamedDocumentReference, NullDocument, StreamToken +from fauna.query.models import DocumentReference, Module, Document, NamedDocument, NamedDocumentReference, NullDocument, \ + StreamToken from fauna.query.query_builder import Query, Fragment, LiteralFragment, ValueFragment _RESERVED_TAGS = [ diff --git a/fauna/errors/__init__.py b/fauna/errors/__init__.py index 4a8211fc..bab6da1f 100644 --- a/fauna/errors/__init__.py +++ b/fauna/errors/__init__.py @@ -1,6 +1,6 @@ -from .errors import FaunaException +from .errors import AuthenticationError, AuthorizationError, QueryCheckError, QueryRuntimeError, \ + QueryTimeoutError, ServiceInternalError, ServiceTimeoutError, ThrottlingError, ContendedTransactionError, \ + InvalidRequestError, AbortError, RetryableFaunaException from .errors import ClientError, FaunaError, NetworkError +from .errors import FaunaException from .errors import ProtocolError, ServiceError -from .errors import AuthenticationError, AuthorizationError, QueryCheckError, QueryRuntimeError, \ - QueryTimeoutError, ServiceInternalError, ServiceTimeoutError, ThrottlingError, ContendedTransactionError, \ - InvalidRequestError, AbortError, RetryableFaunaException diff --git a/fauna/http/http_client.py b/fauna/http/http_client.py index bff18f05..8157bc4e 100644 --- a/fauna/http/http_client.py +++ b/fauna/http/http_client.py @@ -1,8 +1,7 @@ import abc import contextlib - -from typing import Iterator, Mapping, Any, Optional from dataclasses import dataclass +from typing import Iterator, Mapping, Any @dataclass(frozen=True) diff --git a/fauna/http/httpx_client.py b/fauna/http/httpx_client.py index 6625b672..22bc7ddf 100644 --- a/fauna/http/httpx_client.py +++ b/fauna/http/httpx_client.py @@ -1,7 +1,7 @@ import json +from contextlib import contextmanager from json import JSONDecodeError from typing import Mapping, Any, Optional, Iterator -from contextlib import contextmanager import httpx diff --git a/fauna/query/__init__.py b/fauna/query/__init__.py index d433996e..e93730a7 100644 --- a/fauna/query/__init__.py +++ b/fauna/query/__init__.py @@ -1,2 +1,2 @@ -from .query_builder import fql, Query from .models import Document, DocumentReference, NamedDocument, NamedDocumentReference, NullDocument, Module, Page +from .query_builder import fql, Query diff --git a/fauna/query/template.py b/fauna/query/template.py index 4812576b..f91e70de 100644 --- a/fauna/query/template.py +++ b/fauna/query/template.py @@ -1,5 +1,5 @@ -from typing import Optional, Tuple, Iterator, Match import re as _re +from typing import Optional, Tuple, Iterator, Match class FaunaTemplate: diff --git a/tests/integration/test_client.py b/tests/integration/test_client.py index a3365212..d12dc027 100644 --- a/tests/integration/test_client.py +++ b/tests/integration/test_client.py @@ -1,11 +1,11 @@ from datetime import timedelta -import pytest -from fauna.client.client import QueryOptions -from fauna.errors import ClientError +import pytest from fauna import fql from fauna.client import Client +from fauna.client.client import QueryOptions +from fauna.errors import ClientError def test_client_tracks_last_txn_ts(a_collection): diff --git a/tests/integration/test_client_with_query_limits.py b/tests/integration/test_client_with_query_limits.py index 6f5208fb..c6d094e0 100644 --- a/tests/integration/test_client_with_query_limits.py +++ b/tests/integration/test_client_with_query_limits.py @@ -1,6 +1,6 @@ +import os from multiprocessing.pool import ThreadPool from typing import Optional -import os import pytest diff --git a/tests/integration/test_data_type_roundtrips.py b/tests/integration/test_data_type_roundtrips.py index 0a09e73c..8d4e45d5 100644 --- a/tests/integration/test_data_type_roundtrips.py +++ b/tests/integration/test_data_type_roundtrips.py @@ -1,4 +1,3 @@ -import base64 from datetime import datetime, timezone, timedelta from fauna import fql, Document, NamedDocument diff --git a/tests/integration/test_query.py b/tests/integration/test_query.py index 73df836c..0eab317e 100644 --- a/tests/integration/test_query.py +++ b/tests/integration/test_query.py @@ -1,13 +1,13 @@ -from datetime import timedelta import json +from datetime import timedelta from types import SimpleNamespace import pytest from fauna import fql, Page, NullDocument, Module from fauna.client import Client, QueryOptions -from fauna.errors import QueryCheckError, QueryRuntimeError, AbortError, ClientError, QueryTimeoutError from fauna.encoding import ConstraintFailure +from fauna.errors import QueryCheckError, QueryRuntimeError, AbortError, ClientError, QueryTimeoutError def test_query_smoke_test(subtests, client): diff --git a/tests/integration/test_stream.py b/tests/integration/test_stream.py index 484c064e..5260ad82 100644 --- a/tests/integration/test_stream.py +++ b/tests/integration/test_stream.py @@ -1,12 +1,13 @@ import threading import time -import pytest + import httpx -import fauna +import pytest + from fauna import fql from fauna.client import Client, StreamOptions -from fauna.http.httpx_client import HTTPXClient from fauna.errors import NetworkError, RetryableFaunaException, QueryRuntimeError +from fauna.http.httpx_client import HTTPXClient def test_stream(scoped_client): diff --git a/tests/unit/test_client.py b/tests/unit/test_client.py index da390cf4..d03fef61 100644 --- a/tests/unit/test_client.py +++ b/tests/unit/test_client.py @@ -1,6 +1,5 @@ -import json from datetime import timedelta -from typing import Dict, List, Any +from typing import Dict import httpx import pytest @@ -11,8 +10,8 @@ from fauna import fql from fauna.client import Client, Header, QueryOptions, Endpoints, StreamOptions from fauna.errors import QueryCheckError, ProtocolError, QueryRuntimeError, NetworkError, AbortError -from fauna.query.models import StreamToken from fauna.http import HTTPXClient +from fauna.query.models import StreamToken def test_client_defaults(monkeypatch): diff --git a/tests/unit/test_encoding.py b/tests/unit/test_encoding.py index 2edcdb43..ba85b89f 100644 --- a/tests/unit/test_encoding.py +++ b/tests/unit/test_encoding.py @@ -8,7 +8,7 @@ from fauna import fql from fauna.encoding import FaunaEncoder, FaunaDecoder from fauna.query.models import DocumentReference, NamedDocumentReference, Document, NamedDocument, Module, Page, \ - NullDocument, StreamToken + NullDocument, StreamToken fixed_datetime = datetime.fromisoformat("2023-03-17T00:00:00+00:00") diff --git a/tests/unit/test_httpx_client.py b/tests/unit/test_httpx_client.py index 3b2930ac..b1fe437a 100644 --- a/tests/unit/test_httpx_client.py +++ b/tests/unit/test_httpx_client.py @@ -4,7 +4,6 @@ import pytest from pytest_httpx import HTTPXMock, IteratorStream -from fauna.client import Client from fauna.http import HTTPXClient diff --git a/tests/unit/test_models.py b/tests/unit/test_models.py index 375ba5f6..437555ab 100644 --- a/tests/unit/test_models.py +++ b/tests/unit/test_models.py @@ -1,7 +1,7 @@ import datetime from fauna.query.models import Document, Module, NamedDocument, BaseReference, DocumentReference, \ - NamedDocumentReference, Page + NamedDocumentReference, Page fixed_datetime = datetime.datetime.fromisoformat("2023-03-17") diff --git a/tests/unit/test_retryable.py b/tests/unit/test_retryable.py index 7b1174ce..a8bad7de 100644 --- a/tests/unit/test_retryable.py +++ b/tests/unit/test_retryable.py @@ -1,6 +1,7 @@ -import pytest from typing import List, Optional +import pytest + from fauna.client.retryable import Retryable, ExponentialBackoffStrategy from fauna.encoding import QuerySuccess, QueryStats from fauna.errors import ThrottlingError, ServiceError