Skip to content

Commit

Permalink
chore: sort imports (#936)
Browse files Browse the repository at this point in the history
  • Loading branch information
Linchin authored Jul 12, 2024
1 parent 2de1620 commit 719bf49
Show file tree
Hide file tree
Showing 70 changed files with 666 additions and 761 deletions.
51 changes: 26 additions & 25 deletions google/cloud/firestore_v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,42 +23,45 @@

__version__ = package_version.__version__

from typing import List

from google.cloud.firestore_v1 import types
from google.cloud.firestore_v1._helpers import GeoPoint
from google.cloud.firestore_v1._helpers import ExistsOption
from google.cloud.firestore_v1._helpers import LastUpdateOption
from google.cloud.firestore_v1._helpers import ReadAfterWriteError
from google.cloud.firestore_v1._helpers import WriteOption
from google.cloud.firestore_v1.base_aggregation import CountAggregation
from google.cloud.firestore_v1.base_query import And
from google.cloud.firestore_v1.base_query import FieldFilter
from google.cloud.firestore_v1.base_query import Or
from google.cloud.firestore_v1._helpers import (
ExistsOption,
GeoPoint,
LastUpdateOption,
ReadAfterWriteError,
WriteOption,
)
from google.cloud.firestore_v1.async_batch import AsyncWriteBatch
from google.cloud.firestore_v1.async_client import AsyncClient
from google.cloud.firestore_v1.async_collection import AsyncCollectionReference
from google.cloud.firestore_v1.async_document import AsyncDocumentReference
from google.cloud.firestore_v1.async_query import AsyncQuery
from google.cloud.firestore_v1.async_transaction import async_transactional
from google.cloud.firestore_v1.async_transaction import AsyncTransaction
from google.cloud.firestore_v1.async_transaction import (
AsyncTransaction,
async_transactional,
)
from google.cloud.firestore_v1.base_aggregation import CountAggregation
from google.cloud.firestore_v1.base_document import DocumentSnapshot
from google.cloud.firestore_v1.base_query import And, FieldFilter, Or
from google.cloud.firestore_v1.batch import WriteBatch
from google.cloud.firestore_v1.client import Client
from google.cloud.firestore_v1.collection import CollectionReference
from google.cloud.firestore_v1.document import DocumentReference
from google.cloud.firestore_v1.query import CollectionGroup
from google.cloud.firestore_v1.query import Query
from google.cloud.firestore_v1.transaction import Transaction
from google.cloud.firestore_v1.transaction import transactional
from google.cloud.firestore_v1.transforms import ArrayRemove
from google.cloud.firestore_v1.transforms import ArrayUnion
from google.cloud.firestore_v1.transforms import DELETE_FIELD
from google.cloud.firestore_v1.transforms import Increment
from google.cloud.firestore_v1.transforms import Maximum
from google.cloud.firestore_v1.transforms import Minimum
from google.cloud.firestore_v1.transforms import SERVER_TIMESTAMP
from google.cloud.firestore_v1.query import CollectionGroup, Query
from google.cloud.firestore_v1.transaction import Transaction, transactional
from google.cloud.firestore_v1.transforms import (
DELETE_FIELD,
SERVER_TIMESTAMP,
ArrayRemove,
ArrayUnion,
Increment,
Maximum,
Minimum,
)
from google.cloud.firestore_v1.watch import Watch


# TODO(https://github.com/googleapis/python-firestore/issues/93): this is all on the generated surface. We require this to match
# firestore.py. So comment out until needed on customer level for certain.
# from .services.firestore import FirestoreClient
Expand Down Expand Up @@ -102,8 +105,6 @@
# from .types.write import DocumentDelete
# from .types.write import DocumentRemove
from .types.write import DocumentTransform
from typing import List


# from .types.write import ExistenceFilter
# from .types.write import Write
Expand Down
36 changes: 16 additions & 20 deletions google/cloud/firestore_v1/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,6 @@

import datetime
import json

import google
from google.api_core.datetime_helpers import DatetimeWithNanoseconds
from google.api_core import gapic_v1
from google.protobuf import struct_pb2
from google.type import latlng_pb2 # type: ignore
import grpc # type: ignore

from google.cloud import exceptions # type: ignore
from google.cloud._helpers import _datetime_to_pb_timestamp # type: ignore
from google.cloud.firestore_v1.vector import Vector
from google.cloud.firestore_v1.types.write import DocumentTransform
from google.cloud.firestore_v1 import transforms
from google.cloud.firestore_v1 import types
from google.cloud.firestore_v1.field_path import FieldPath
from google.cloud.firestore_v1.field_path import parse_field_path
from google.cloud.firestore_v1.types import common
from google.cloud.firestore_v1.types import document
from google.cloud.firestore_v1.types import write
from google.protobuf.timestamp_pb2 import Timestamp # type: ignore
from typing import (
Any,
Dict,
Expand All @@ -48,6 +28,22 @@
Union,
)

import grpc # type: ignore
from google.api_core import gapic_v1
from google.api_core.datetime_helpers import DatetimeWithNanoseconds
from google.cloud._helpers import _datetime_to_pb_timestamp # type: ignore
from google.protobuf import struct_pb2
from google.protobuf.timestamp_pb2 import Timestamp # type: ignore
from google.type import latlng_pb2 # type: ignore

import google
from google.cloud import exceptions # type: ignore
from google.cloud.firestore_v1 import transforms, types
from google.cloud.firestore_v1.field_path import FieldPath, parse_field_path
from google.cloud.firestore_v1.types import common, document, write
from google.cloud.firestore_v1.types.write import DocumentTransform
from google.cloud.firestore_v1.vector import Vector

_EmptyDict: transforms.Sentinel
_GRPC_ERROR_MAPPING: dict

Expand Down
8 changes: 3 additions & 5 deletions google/cloud/firestore_v1/aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"""
from __future__ import annotations

from google.api_core import exceptions
from google.api_core import gapic_v1
from google.api_core import retry as retries
from typing import TYPE_CHECKING, Any, Generator, List, Optional, Union

from google.api_core import exceptions, gapic_v1
from google.api_core import retry as retries

from google.cloud.firestore_v1.base_aggregation import (
AggregationResult,
Expand All @@ -33,8 +33,6 @@
from google.cloud.firestore_v1.base_document import DocumentSnapshot
from google.cloud.firestore_v1.stream_generator import StreamGenerator

from typing import Any, Generator, List, Optional, TYPE_CHECKING, Union

# Types needed only for Type Hints
if TYPE_CHECKING:
from google.cloud.firestore_v1 import transaction # pragma: NO COVER
Expand Down
8 changes: 4 additions & 4 deletions google/cloud/firestore_v1/async_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
"""
from __future__ import annotations

from typing import TYPE_CHECKING, AsyncGenerator, List, Optional, Union

from google.api_core import gapic_v1
from google.api_core import retry_async as retries

from typing import AsyncGenerator, List, Optional, Union, TYPE_CHECKING

from google.cloud.firestore_v1 import transaction
from google.cloud.firestore_v1.async_stream_generator import AsyncStreamGenerator
from google.cloud.firestore_v1.base_aggregation import (
AggregationResult,
_query_response_to_result,
BaseAggregationQuery,
_query_response_to_result,
)
from google.cloud.firestore_v1 import transaction

if TYPE_CHECKING: # pragma: NO COVER
from google.cloud.firestore_v1.base_document import DocumentSnapshot
Expand Down
14 changes: 5 additions & 9 deletions google/cloud/firestore_v1/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,28 @@
:class:`~google.cloud.firestore_v1.async_document.AsyncDocumentReference`
"""

from typing import TYPE_CHECKING, Any, AsyncGenerator, Iterable, List, Optional, Union

from google.api_core import gapic_v1
from google.api_core import retry_async as retries

from google.cloud.firestore_v1.base_client import (
BaseClient,
_CLIENT_INFO,
_parse_batch_get, # type: ignore
_path_helper,
)

from google.cloud.firestore_v1.async_query import AsyncCollectionGroup
from google.cloud.firestore_v1.async_batch import AsyncWriteBatch
from google.cloud.firestore_v1.async_collection import AsyncCollectionReference
from google.cloud.firestore_v1.async_document import (
AsyncDocumentReference,
DocumentSnapshot,
)
from google.cloud.firestore_v1.async_query import AsyncCollectionGroup
from google.cloud.firestore_v1.async_transaction import AsyncTransaction
from google.cloud.firestore_v1.base_client import _parse_batch_get # type: ignore
from google.cloud.firestore_v1.base_client import _CLIENT_INFO, BaseClient, _path_helper
from google.cloud.firestore_v1.field_path import FieldPath
from google.cloud.firestore_v1.services.firestore import (
async_client as firestore_client,
)
from google.cloud.firestore_v1.services.firestore.transports import (
grpc_asyncio as firestore_grpc_transport,
)
from typing import Any, AsyncGenerator, Iterable, List, Optional, Union, TYPE_CHECKING

if TYPE_CHECKING:
from google.cloud.firestore_v1.bulk_writer import BulkWriter # pragma: NO COVER
Expand Down
13 changes: 6 additions & 7 deletions google/cloud/firestore_v1/async_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,23 @@

"""Classes for representing collections for the Google Cloud Firestore API."""

from typing import TYPE_CHECKING, Any, AsyncGenerator, Optional, Tuple

from google.api_core import gapic_v1
from google.api_core import retry_async as retries

from google.cloud.firestore_v1.base_collection import (
BaseCollectionReference,
_item_to_document_ref,
)
from google.cloud.firestore_v1 import (
async_aggregation,
async_document,
async_query,
transaction,
)

from google.cloud.firestore_v1.base_collection import (
BaseCollectionReference,
_item_to_document_ref,
)
from google.cloud.firestore_v1.document import DocumentReference

from typing import Any, AsyncGenerator, Optional, Tuple, TYPE_CHECKING

if TYPE_CHECKING: # pragma: NO COVER
from google.cloud.firestore_v1.async_stream_generator import AsyncStreamGenerator
from google.cloud.firestore_v1.base_document import DocumentSnapshot
Expand Down
7 changes: 3 additions & 4 deletions google/cloud/firestore_v1/async_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,20 @@
"""Classes for representing documents for the Google Cloud Firestore API."""
import datetime
import logging
from typing import AsyncGenerator, Iterable

from google.api_core import gapic_v1
from google.api_core import retry_async as retries
from google.cloud._helpers import _datetime_to_pb_timestamp # type: ignore
from google.protobuf.timestamp_pb2 import Timestamp

from google.cloud.firestore_v1 import _helpers
from google.cloud.firestore_v1.base_document import (
BaseDocumentReference,
DocumentSnapshot,
_first_write_result,
)
from google.cloud.firestore_v1 import _helpers
from google.cloud.firestore_v1.types import write
from google.protobuf.timestamp_pb2 import Timestamp
from typing import AsyncGenerator, Iterable


logger = logging.getLogger(__name__)

Expand Down
15 changes: 7 additions & 8 deletions google/cloud/firestore_v1/async_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,25 @@
"""
from __future__ import annotations

from typing import TYPE_CHECKING, AsyncGenerator, List, Optional, Type

from google.api_core import gapic_v1
from google.api_core import retry_async as retries

from google.cloud import firestore_v1
from google.cloud.firestore_v1 import async_document, transaction
from google.cloud.firestore_v1.async_aggregation import AsyncAggregationQuery
from google.cloud.firestore_v1.async_stream_generator import AsyncStreamGenerator
from google.cloud.firestore_v1.async_vector_query import AsyncVectorQuery
from google.cloud.firestore_v1.base_query import (
BaseCollectionGroup,
BaseQuery,
QueryPartition,
_query_response_to_snapshot,
_collection_group_query_response_to_snapshot,
_enum_from_direction,
_query_response_to_snapshot,
)

from google.cloud.firestore_v1 import async_document
from google.cloud.firestore_v1.async_aggregation import AsyncAggregationQuery
from google.cloud.firestore_v1.async_vector_query import AsyncVectorQuery
from google.cloud.firestore_v1.async_stream_generator import AsyncStreamGenerator
from google.cloud.firestore_v1 import transaction
from typing import AsyncGenerator, List, Optional, Type, TYPE_CHECKING

if TYPE_CHECKING: # pragma: NO COVER
# Types needed only for Type Hints
from google.cloud.firestore_v1.base_document import DocumentSnapshot
Expand Down
31 changes: 14 additions & 17 deletions google/cloud/firestore_v1/async_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,31 @@

import asyncio
import random
from typing import Any, AsyncGenerator, Callable, Coroutine

from google.api_core import gapic_v1
from google.api_core import exceptions, gapic_v1
from google.api_core import retry_async as retries

from google.cloud.firestore_v1 import _helpers, async_batch, types
from google.cloud.firestore_v1.async_document import (
AsyncDocumentReference,
DocumentSnapshot,
)
from google.cloud.firestore_v1.async_query import AsyncQuery
from google.cloud.firestore_v1.base_transaction import (
_BaseTransactional,
BaseTransaction,
MAX_ATTEMPTS,
_CANT_BEGIN,
_CANT_ROLLBACK,
_CANT_COMMIT,
_WRITE_READ_ONLY,
_CANT_ROLLBACK,
_EXCEED_ATTEMPTS_TEMPLATE,
_INITIAL_SLEEP,
_MAX_SLEEP,
_MULTIPLIER,
_EXCEED_ATTEMPTS_TEMPLATE,
_WRITE_READ_ONLY,
MAX_ATTEMPTS,
BaseTransaction,
_BaseTransactional,
)

from google.api_core import exceptions
from google.cloud.firestore_v1 import async_batch
from google.cloud.firestore_v1 import _helpers
from google.cloud.firestore_v1 import types

from google.cloud.firestore_v1.async_document import AsyncDocumentReference
from google.cloud.firestore_v1.async_document import DocumentSnapshot
from google.cloud.firestore_v1.async_query import AsyncQuery
from typing import Any, AsyncGenerator, Callable, Coroutine

# Types needed only for Type Hints
from google.cloud.firestore_v1.client import Client

Expand Down
6 changes: 4 additions & 2 deletions google/cloud/firestore_v1/async_vector_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@

from __future__ import annotations

from typing import AsyncGenerator, List, Optional, TypeVar, Union

from google.api_core import gapic_v1
from google.api_core import retry_async as retries

from google.cloud.firestore_v1 import async_document
from google.cloud.firestore_v1.base_document import DocumentSnapshot
from google.cloud.firestore_v1.base_query import (
BaseQuery,
_query_response_to_snapshot,
_collection_group_query_response_to_snapshot,
_query_response_to_snapshot,
)
from google.cloud.firestore_v1.base_vector_query import BaseVectorQuery
from typing import AsyncGenerator, List, Union, Optional, TypeVar

TAsyncVectorQuery = TypeVar("TAsyncVectorQuery", bound="AsyncVectorQuery")

Expand Down
Loading

0 comments on commit 719bf49

Please sign in to comment.