From 6f6bb63219ac4369d16d39d5ec7b22bffe59c48f Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 7 Dec 2022 13:53:23 -0500 Subject: [PATCH] fix(deps): Require google-api-core >=1.34.0, >=2.11.0 (#390) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(deps): Require google-api-core >=1.34.0, >=2.11.0 fix: Drop usage of pkg_resources fix: Fix timeout default values docs(samples): Snippetgen should call await on the operation coroutine before calling result PiperOrigin-RevId: 493260409 Source-Link: https://github.com/googleapis/googleapis/commit/fea43879f83a8d0dacc9353b3f75f8f46d37162f Source-Link: https://github.com/googleapis/googleapis-gen/commit/387b7344c7529ee44be84e613b19a820508c612b Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMzg3YjczNDRjNzUyOWVlNDRiZTg0ZTYxM2IxOWE4MjA1MDhjNjEyYiJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix(deps): require google-api-core>=1.34.0,>=2.11.0 * fix cover * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * revert * set coverage level to 99 * set coverage level to 100 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * add test * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * add test Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- .coveragerc | 5 --- google/cloud/datastore_admin_v1/__init__.py | 2 +- .../cloud/datastore_admin_v1/gapic_version.py | 15 ++++++++ .../services/datastore_admin/async_client.py | 34 ++++++++--------- .../services/datastore_admin/client.py | 26 ++++++------- .../datastore_admin/transports/base.py | 14 +++---- google/cloud/datastore_v1/__init__.py | 2 +- google/cloud/datastore_v1/gapic_version.py | 15 ++++++++ .../services/datastore/async_client.py | 38 +++++++++---------- .../datastore_v1/services/datastore/client.py | 38 +++++++++---------- .../services/datastore/transports/base.py | 14 +++---- owlbot.py | 4 +- setup.py | 2 +- testing/constraints-3.7.txt | 2 +- tests/unit/test__gapic.py | 11 ++++++ 15 files changed, 117 insertions(+), 105 deletions(-) create mode 100644 google/cloud/datastore_admin_v1/gapic_version.py create mode 100644 google/cloud/datastore_v1/gapic_version.py diff --git a/.coveragerc b/.coveragerc index cab8fd72..fc99a17b 100644 --- a/.coveragerc +++ b/.coveragerc @@ -30,8 +30,3 @@ exclude_lines = pragma: NO COVER # Ignore debug-only repr def __repr__ - # Ignore pkg_resources exceptions. - # This is added at the module level as a safeguard for if someone - # generates the code and tries to run it without pip installing. This - # makes it virtually impossible to test properly. - except pkg_resources.DistributionNotFound diff --git a/google/cloud/datastore_admin_v1/__init__.py b/google/cloud/datastore_admin_v1/__init__.py index 4b0552de..d2b8b534 100644 --- a/google/cloud/datastore_admin_v1/__init__.py +++ b/google/cloud/datastore_admin_v1/__init__.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from google.cloud.datastore_admin import gapic_version as package_version +from google.cloud.datastore_admin_v1 import gapic_version as package_version __version__ = package_version.__version__ diff --git a/google/cloud/datastore_admin_v1/gapic_version.py b/google/cloud/datastore_admin_v1/gapic_version.py new file mode 100644 index 00000000..3aec9442 --- /dev/null +++ b/google/cloud/datastore_admin_v1/gapic_version.py @@ -0,0 +1,15 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +__version__ = "2.11.0" # {x-release-please-version} diff --git a/google/cloud/datastore_admin_v1/services/datastore_admin/async_client.py b/google/cloud/datastore_admin_v1/services/datastore_admin/async_client.py index bd96febe..ad1ced59 100644 --- a/google/cloud/datastore_admin_v1/services/datastore_admin/async_client.py +++ b/google/cloud/datastore_admin_v1/services/datastore_admin/async_client.py @@ -27,7 +27,8 @@ Type, Union, ) -import pkg_resources + +from google.cloud.datastore_admin_v1 import gapic_version as package_version from google.api_core.client_options import ClientOptions from google.api_core import exceptions as core_exceptions @@ -281,7 +282,7 @@ async def export_entities( entity_filter: Optional[datastore_admin.EntityFilter] = None, output_url_prefix: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Exports a copy of all or a subset of entities from @@ -321,7 +322,7 @@ async def sample_export_entities(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -462,7 +463,7 @@ async def import_entities( input_url: Optional[str] = None, entity_filter: Optional[datastore_admin.EntityFilter] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Imports entities into Google Cloud Datastore. @@ -499,7 +500,7 @@ async def sample_import_entities(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -637,7 +638,7 @@ async def create_index( request: Optional[Union[datastore_admin.CreateIndexRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Creates the specified index. A newly created index's initial @@ -680,7 +681,7 @@ async def sample_create_index(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -747,7 +748,7 @@ async def delete_index( request: Optional[Union[datastore_admin.DeleteIndexRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation_async.AsyncOperation: r"""Deletes an existing index. An index can only be deleted if it is @@ -789,7 +790,7 @@ async def sample_delete_index(): print("Waiting for operation to complete...") - response = await operation.result() + response = (await operation).result() # Handle the response print(response) @@ -859,7 +860,7 @@ async def get_index( request: Optional[Union[datastore_admin.GetIndexRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> index.Index: r"""Gets an index. @@ -951,7 +952,7 @@ async def list_indexes( request: Optional[Union[datastore_admin.ListIndexesRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListIndexesAsyncPager: r"""Lists the indexes that match the specified filters. @@ -1060,14 +1061,9 @@ async def __aexit__(self, exc_type, exc, tb): await self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-datastore-admin", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("DatastoreAdminAsyncClient",) diff --git a/google/cloud/datastore_admin_v1/services/datastore_admin/client.py b/google/cloud/datastore_admin_v1/services/datastore_admin/client.py index 4c00fb94..e1ab3a59 100644 --- a/google/cloud/datastore_admin_v1/services/datastore_admin/client.py +++ b/google/cloud/datastore_admin_v1/services/datastore_admin/client.py @@ -28,7 +28,8 @@ Union, cast, ) -import pkg_resources + +from google.cloud.datastore_admin_v1 import gapic_version as package_version from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions @@ -485,7 +486,7 @@ def export_entities( entity_filter: Optional[datastore_admin.EntityFilter] = None, output_url_prefix: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Exports a copy of all or a subset of entities from @@ -665,7 +666,7 @@ def import_entities( input_url: Optional[str] = None, entity_filter: Optional[datastore_admin.EntityFilter] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Imports entities into Google Cloud Datastore. @@ -839,7 +840,7 @@ def create_index( request: Optional[Union[datastore_admin.CreateIndexRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Creates the specified index. A newly created index's initial @@ -950,7 +951,7 @@ def delete_index( request: Optional[Union[datastore_admin.DeleteIndexRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operation.Operation: r"""Deletes an existing index. An index can only be deleted if it is @@ -1063,7 +1064,7 @@ def get_index( request: Optional[Union[datastore_admin.GetIndexRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> index.Index: r"""Gets an index. @@ -1146,7 +1147,7 @@ def list_indexes( request: Optional[Union[datastore_admin.ListIndexesRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> pagers.ListIndexesPager: r"""Lists the indexes that match the specified filters. @@ -1253,14 +1254,9 @@ def __exit__(self, type, value, traceback): self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-datastore-admin", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("DatastoreAdminClient",) diff --git a/google/cloud/datastore_admin_v1/services/datastore_admin/transports/base.py b/google/cloud/datastore_admin_v1/services/datastore_admin/transports/base.py index 23175bd2..72391f4b 100644 --- a/google/cloud/datastore_admin_v1/services/datastore_admin/transports/base.py +++ b/google/cloud/datastore_admin_v1/services/datastore_admin/transports/base.py @@ -15,7 +15,8 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import pkg_resources + +from google.cloud.datastore_admin_v1 import gapic_version as package_version import google.auth # type: ignore import google.api_core @@ -30,14 +31,9 @@ from google.cloud.datastore_admin_v1.types import index from google.longrunning import operations_pb2 # type: ignore -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-datastore-admin", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) class DatastoreAdminTransport(abc.ABC): diff --git a/google/cloud/datastore_v1/__init__.py b/google/cloud/datastore_v1/__init__.py index b868c406..05159e68 100644 --- a/google/cloud/datastore_v1/__init__.py +++ b/google/cloud/datastore_v1/__init__.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from google.cloud.datastore import gapic_version as package_version +from google.cloud.datastore_v1 import gapic_version as package_version __version__ = package_version.__version__ diff --git a/google/cloud/datastore_v1/gapic_version.py b/google/cloud/datastore_v1/gapic_version.py new file mode 100644 index 00000000..3aec9442 --- /dev/null +++ b/google/cloud/datastore_v1/gapic_version.py @@ -0,0 +1,15 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +__version__ = "2.11.0" # {x-release-please-version} diff --git a/google/cloud/datastore_v1/services/datastore/async_client.py b/google/cloud/datastore_v1/services/datastore/async_client.py index 1986c2b5..ece12c50 100644 --- a/google/cloud/datastore_v1/services/datastore/async_client.py +++ b/google/cloud/datastore_v1/services/datastore/async_client.py @@ -27,7 +27,8 @@ Type, Union, ) -import pkg_resources + +from google.cloud.datastore_v1 import gapic_version as package_version from google.api_core.client_options import ClientOptions from google.api_core import exceptions as core_exceptions @@ -223,7 +224,7 @@ async def lookup( read_options: Optional[datastore.ReadOptions] = None, keys: Optional[MutableSequence[entity.Key]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> datastore.LookupResponse: r"""Looks up entities by key. @@ -352,7 +353,7 @@ async def run_query( request: Optional[Union[datastore.RunQueryRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> datastore.RunQueryResponse: r"""Queries for entities. @@ -444,7 +445,7 @@ async def run_aggregation_query( request: Optional[Union[datastore.RunAggregationQueryRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> datastore.RunAggregationQueryResponse: r"""Runs an aggregation query. @@ -537,7 +538,7 @@ async def begin_transaction( *, project_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> datastore.BeginTransactionResponse: r"""Begins a new transaction. @@ -644,7 +645,7 @@ async def commit( transaction: Optional[bytes] = None, mutations: Optional[MutableSequence[datastore.Mutation]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> datastore.CommitResponse: r"""Commits a transaction, optionally creating, deleting @@ -792,7 +793,7 @@ async def rollback( project_id: Optional[str] = None, transaction: Optional[bytes] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> datastore.RollbackResponse: r"""Rolls back a transaction. @@ -908,7 +909,7 @@ async def allocate_ids( project_id: Optional[str] = None, keys: Optional[MutableSequence[entity.Key]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> datastore.AllocateIdsResponse: r"""Allocates IDs for the given keys, which is useful for @@ -1025,7 +1026,7 @@ async def reserve_ids( project_id: Optional[str] = None, keys: Optional[MutableSequence[entity.Key]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> datastore.ReserveIdsResponse: r"""Prevents the supplied keys' IDs from being @@ -1149,7 +1150,7 @@ async def list_operations( request: Optional[operations_pb2.ListOperationsRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1203,7 +1204,7 @@ async def get_operation( request: Optional[operations_pb2.GetOperationRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1257,7 +1258,7 @@ async def delete_operation( request: Optional[operations_pb2.DeleteOperationRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1312,7 +1313,7 @@ async def cancel_operation( request: Optional[operations_pb2.CancelOperationRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -1368,14 +1369,9 @@ async def __aexit__(self, exc_type, exc, tb): await self.transport.close() -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-datastore", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("DatastoreAsyncClient",) diff --git a/google/cloud/datastore_v1/services/datastore/client.py b/google/cloud/datastore_v1/services/datastore/client.py index 5d744620..8693049c 100644 --- a/google/cloud/datastore_v1/services/datastore/client.py +++ b/google/cloud/datastore_v1/services/datastore/client.py @@ -28,7 +28,8 @@ Union, cast, ) -import pkg_resources + +from google.cloud.datastore_v1 import gapic_version as package_version from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions @@ -434,7 +435,7 @@ def lookup( read_options: Optional[datastore.ReadOptions] = None, keys: Optional[MutableSequence[entity.Key]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> datastore.LookupResponse: r"""Looks up entities by key. @@ -553,7 +554,7 @@ def run_query( request: Optional[Union[datastore.RunQueryRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> datastore.RunQueryResponse: r"""Queries for entities. @@ -636,7 +637,7 @@ def run_aggregation_query( request: Optional[Union[datastore.RunAggregationQueryRequest, dict]] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> datastore.RunAggregationQueryResponse: r"""Runs an aggregation query. @@ -720,7 +721,7 @@ def begin_transaction( *, project_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> datastore.BeginTransactionResponse: r"""Begins a new transaction. @@ -827,7 +828,7 @@ def commit( transaction: Optional[bytes] = None, mutations: Optional[MutableSequence[datastore.Mutation]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> datastore.CommitResponse: r"""Commits a transaction, optionally creating, deleting @@ -975,7 +976,7 @@ def rollback( project_id: Optional[str] = None, transaction: Optional[bytes] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> datastore.RollbackResponse: r"""Rolls back a transaction. @@ -1091,7 +1092,7 @@ def allocate_ids( project_id: Optional[str] = None, keys: Optional[MutableSequence[entity.Key]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> datastore.AllocateIdsResponse: r"""Allocates IDs for the given keys, which is useful for @@ -1208,7 +1209,7 @@ def reserve_ids( project_id: Optional[str] = None, keys: Optional[MutableSequence[entity.Key]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> datastore.ReserveIdsResponse: r"""Prevents the supplied keys' IDs from being @@ -1335,7 +1336,7 @@ def list_operations( request: Optional[operations_pb2.ListOperationsRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Lists operations that match the specified filter in the request. @@ -1389,7 +1390,7 @@ def get_operation( request: Optional[operations_pb2.GetOperationRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> operations_pb2.Operation: r"""Gets the latest state of a long-running operation. @@ -1443,7 +1444,7 @@ def delete_operation( request: Optional[operations_pb2.DeleteOperationRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Deletes a long-running operation. @@ -1498,7 +1499,7 @@ def cancel_operation( request: Optional[operations_pb2.CancelOperationRequest] = None, *, retry: OptionalRetry = gapic_v1.method.DEFAULT, - timeout: Optional[float] = None, + timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (), ) -> None: r"""Starts asynchronous cancellation on a long-running operation. @@ -1548,14 +1549,9 @@ def cancel_operation( ) -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-datastore", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) __all__ = ("DatastoreClient",) diff --git a/google/cloud/datastore_v1/services/datastore/transports/base.py b/google/cloud/datastore_v1/services/datastore/transports/base.py index c9b14ea8..1e7a3c94 100644 --- a/google/cloud/datastore_v1/services/datastore/transports/base.py +++ b/google/cloud/datastore_v1/services/datastore/transports/base.py @@ -15,7 +15,8 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import pkg_resources + +from google.cloud.datastore_v1 import gapic_version as package_version import google.auth # type: ignore import google.api_core @@ -28,14 +29,9 @@ from google.cloud.datastore_v1.types import datastore from google.longrunning import operations_pb2 -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google-cloud-datastore", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=package_version.__version__ +) class DatastoreTransport(abc.ABC): diff --git a/owlbot.py b/owlbot.py index 60fc4172..d5040231 100644 --- a/owlbot.py +++ b/owlbot.py @@ -68,7 +68,7 @@ def get_staging_dirs( datastore_admin_default_version = "v1" for library in get_staging_dirs(datastore_default_version, "datastore"): - s.move(library / f"google/cloud/datastore_{library.name}") + s.move(library / f"google/cloud/datastore_{library.name}", excludes=["**/gapic_version.py"]) s.move(library / "tests/") s.move(library / "scripts") @@ -87,7 +87,7 @@ def get_staging_dirs( ) s.move(library / f"google/cloud/datastore_admin", excludes=["**/gapic_version.py"]) - s.move(library / f"google/cloud/datastore_admin_{library.name}") + s.move(library / f"google/cloud/datastore_admin_{library.name}", excludes=["**/gapic_version.py"]) s.move(library / "tests") s.move(library / "scripts") diff --git a/setup.py b/setup.py index af39cfa4..a64557cb 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ # 'Development Status :: 5 - Production/Stable' release_status = "Development Status :: 5 - Production/Stable" dependencies = [ - "google-api-core[grpc] >= 1.32.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*", + "google-api-core[grpc] >= 1.34.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*", "google-cloud-core >= 1.4.0, <3.0.0dev", "proto-plus >= 1.22.0, <2.0.0dev", "protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt index 5ee7f9ee..4b49551c 100644 --- a/testing/constraints-3.7.txt +++ b/testing/constraints-3.7.txt @@ -5,7 +5,7 @@ # # e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", # Then this file should have foo==1.14.0 -google-api-core==1.32.0 +google-api-core==1.34.0 google-cloud-core==1.4.0 proto-plus==1.22.0 libcst==0.2.5 diff --git a/tests/unit/test__gapic.py b/tests/unit/test__gapic.py index b72a68b5..b515aba8 100644 --- a/tests/unit/test__gapic.py +++ b/tests/unit/test__gapic.py @@ -92,3 +92,14 @@ def test_emulator(make_chan, mock_transport, mock_klass): mock_klass.assert_called_once_with( transport=mock.sentinel.transport, client_info=mock.sentinel.client_info ) + + +def test_version_from_gapic_version_matches_datastore_version(): + from google.cloud.datastore import gapic_version + from google.cloud.datastore_v1 import gapic_version as gapic_version_v1 + from google.cloud.datastore_admin import gapic_version as gapic_version_admin + from google.cloud.datastore_admin_v1 import gapic_version as gapic_version_admin_v1 + + assert gapic_version.__version__ == gapic_version_admin.__version__ + assert gapic_version.__version__ == gapic_version_v1.__version__ + assert gapic_version.__version__ == gapic_version_admin_v1.__version__