Skip to content

Commit 4dcb970

Browse files
chore: use gapic-generator-python 0.53.4 (#263)
- [ ] Regenerate this pull request now. docs: list oneofs in docstring fix(deps): require google-api-core >= 1.28.0 fix(deps): drop packaging dependency committer: busunkim96@ PiperOrigin-RevId: 406468269 Source-Link: googleapis/googleapis@83d81b0 Source-Link: googleapis/googleapis-gen@2ff001f Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMmZmMDAxZmJhY2I5ZTc3ZTcxZDczNGRlNWY5NTVjMDVmZGFlODUyNiJ9
1 parent f051f94 commit 4dcb970

File tree

52 files changed

+464
-1317
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+464
-1317
lines changed

packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/async_client.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
from typing import Dict, Sequence, Tuple, Type, Union
2020
import pkg_resources
2121

22-
import google.api_core.client_options as ClientOptions # type: ignore
22+
from google.api_core.client_options import ClientOptions # type: ignore
2323
from google.api_core import exceptions as core_exceptions # type: ignore
2424
from google.api_core import gapic_v1 # type: ignore
2525
from google.api_core import retry as retries # type: ignore
2626
from google.auth import credentials as ga_credentials # type: ignore
2727
from google.oauth2 import service_account # type: ignore
2828

29+
OptionalRetry = Union[retries.Retry, object]
30+
2931
from google.api_core import operation # type: ignore
3032
from google.api_core import operation_async # type: ignore
3133
from google.cloud.vision_v1.types import image_annotator
@@ -170,18 +172,18 @@ def __init__(
170172

171173
async def batch_annotate_images(
172174
self,
173-
request: image_annotator.BatchAnnotateImagesRequest = None,
175+
request: Union[image_annotator.BatchAnnotateImagesRequest, dict] = None,
174176
*,
175177
requests: Sequence[image_annotator.AnnotateImageRequest] = None,
176-
retry: retries.Retry = gapic_v1.method.DEFAULT,
178+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
177179
timeout: float = None,
178180
metadata: Sequence[Tuple[str, str]] = (),
179181
) -> image_annotator.BatchAnnotateImagesResponse:
180182
r"""Run image detection and annotation for a batch of
181183
images.
182184
183185
Args:
184-
request (:class:`google.cloud.vision_v1.types.BatchAnnotateImagesRequest`):
186+
request (Union[google.cloud.vision_v1.types.BatchAnnotateImagesRequest, dict]):
185187
The request object. Multiple image annotation requests
186188
are batched into a single service call.
187189
requests (:class:`Sequence[google.cloud.vision_v1.types.AnnotateImageRequest]`):
@@ -246,10 +248,10 @@ async def batch_annotate_images(
246248

247249
async def batch_annotate_files(
248250
self,
249-
request: image_annotator.BatchAnnotateFilesRequest = None,
251+
request: Union[image_annotator.BatchAnnotateFilesRequest, dict] = None,
250252
*,
251253
requests: Sequence[image_annotator.AnnotateFileRequest] = None,
252-
retry: retries.Retry = gapic_v1.method.DEFAULT,
254+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
253255
timeout: float = None,
254256
metadata: Sequence[Tuple[str, str]] = (),
255257
) -> image_annotator.BatchAnnotateFilesResponse:
@@ -263,7 +265,7 @@ async def batch_annotate_files(
263265
extracted.
264266
265267
Args:
266-
request (:class:`google.cloud.vision_v1.types.BatchAnnotateFilesRequest`):
268+
request (Union[google.cloud.vision_v1.types.BatchAnnotateFilesRequest, dict]):
267269
The request object. A list of requests to annotate files
268270
using the BatchAnnotateFiles API.
269271
requests (:class:`Sequence[google.cloud.vision_v1.types.AnnotateFileRequest]`):
@@ -328,11 +330,11 @@ async def batch_annotate_files(
328330

329331
async def async_batch_annotate_images(
330332
self,
331-
request: image_annotator.AsyncBatchAnnotateImagesRequest = None,
333+
request: Union[image_annotator.AsyncBatchAnnotateImagesRequest, dict] = None,
332334
*,
333335
requests: Sequence[image_annotator.AnnotateImageRequest] = None,
334336
output_config: image_annotator.OutputConfig = None,
335-
retry: retries.Retry = gapic_v1.method.DEFAULT,
337+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
336338
timeout: float = None,
337339
metadata: Sequence[Tuple[str, str]] = (),
338340
) -> operation_async.AsyncOperation:
@@ -350,7 +352,7 @@ async def async_batch_annotate_images(
350352
BatchAnnotateImagesResponse proto.
351353
352354
Args:
353-
request (:class:`google.cloud.vision_v1.types.AsyncBatchAnnotateImagesRequest`):
355+
request (Union[google.cloud.vision_v1.types.AsyncBatchAnnotateImagesRequest, dict]):
354356
The request object. Request for async image annotation
355357
for a list of images.
356358
requests (:class:`Sequence[google.cloud.vision_v1.types.AnnotateImageRequest]`):
@@ -435,10 +437,10 @@ async def async_batch_annotate_images(
435437

436438
async def async_batch_annotate_files(
437439
self,
438-
request: image_annotator.AsyncBatchAnnotateFilesRequest = None,
440+
request: Union[image_annotator.AsyncBatchAnnotateFilesRequest, dict] = None,
439441
*,
440442
requests: Sequence[image_annotator.AsyncAnnotateFileRequest] = None,
441-
retry: retries.Retry = gapic_v1.method.DEFAULT,
443+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
442444
timeout: float = None,
443445
metadata: Sequence[Tuple[str, str]] = (),
444446
) -> operation_async.AsyncOperation:
@@ -451,7 +453,7 @@ async def async_batch_annotate_files(
451453
``AsyncBatchAnnotateFilesResponse`` (results).
452454
453455
Args:
454-
request (:class:`google.cloud.vision_v1.types.AsyncBatchAnnotateFilesRequest`):
456+
request (Union[google.cloud.vision_v1.types.AsyncBatchAnnotateFilesRequest, dict]):
455457
The request object. Multiple async file annotation
456458
requests are batched into a single service call.
457459
requests (:class:`Sequence[google.cloud.vision_v1.types.AsyncAnnotateFileRequest]`):

packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/client.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
from google.auth.exceptions import MutualTLSChannelError # type: ignore
3131
from google.oauth2 import service_account # type: ignore
3232

33+
OptionalRetry = Union[retries.Retry, object]
34+
3335
from google.api_core import operation # type: ignore
3436
from google.api_core import operation_async # type: ignore
3537
from google.cloud.vision_v1.types import image_annotator
@@ -373,7 +375,7 @@ def batch_annotate_images(
373375
request: Union[image_annotator.BatchAnnotateImagesRequest, dict] = None,
374376
*,
375377
requests: Sequence[image_annotator.AnnotateImageRequest] = None,
376-
retry: retries.Retry = gapic_v1.method.DEFAULT,
378+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
377379
timeout: float = None,
378380
metadata: Sequence[Tuple[str, str]] = (),
379381
) -> image_annotator.BatchAnnotateImagesResponse:
@@ -442,7 +444,7 @@ def batch_annotate_files(
442444
request: Union[image_annotator.BatchAnnotateFilesRequest, dict] = None,
443445
*,
444446
requests: Sequence[image_annotator.AnnotateFileRequest] = None,
445-
retry: retries.Retry = gapic_v1.method.DEFAULT,
447+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
446448
timeout: float = None,
447449
metadata: Sequence[Tuple[str, str]] = (),
448450
) -> image_annotator.BatchAnnotateFilesResponse:
@@ -518,7 +520,7 @@ def async_batch_annotate_images(
518520
*,
519521
requests: Sequence[image_annotator.AnnotateImageRequest] = None,
520522
output_config: image_annotator.OutputConfig = None,
521-
retry: retries.Retry = gapic_v1.method.DEFAULT,
523+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
522524
timeout: float = None,
523525
metadata: Sequence[Tuple[str, str]] = (),
524526
) -> operation.Operation:
@@ -619,7 +621,7 @@ def async_batch_annotate_files(
619621
request: Union[image_annotator.AsyncBatchAnnotateFilesRequest, dict] = None,
620622
*,
621623
requests: Sequence[image_annotator.AsyncAnnotateFileRequest] = None,
622-
retry: retries.Retry = gapic_v1.method.DEFAULT,
624+
retry: OptionalRetry = gapic_v1.method.DEFAULT,
623625
timeout: float = None,
624626
metadata: Sequence[Tuple[str, str]] = (),
625627
) -> operation.Operation:

packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/base.py

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#
1616
import abc
1717
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
18-
import packaging.version
1918
import pkg_resources
2019

2120
import google.auth # type: ignore
@@ -37,15 +36,6 @@
3736
except pkg_resources.DistributionNotFound:
3837
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
3938

40-
try:
41-
# google.auth.__version__ was added in 1.26.0
42-
_GOOGLE_AUTH_VERSION = google.auth.__version__
43-
except AttributeError:
44-
try: # try pkg_resources if it is available
45-
_GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version
46-
except pkg_resources.DistributionNotFound: # pragma: NO COVER
47-
_GOOGLE_AUTH_VERSION = None
48-
4939

5040
class ImageAnnotatorTransport(abc.ABC):
5141
"""Abstract transport class for ImageAnnotator."""
@@ -98,7 +88,7 @@ def __init__(
9888
host += ":443"
9989
self._host = host
10090

101-
scopes_kwargs = self._get_scopes_kwargs(self._host, scopes)
91+
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}
10292

10393
# Save the scopes.
10494
self._scopes = scopes
@@ -131,29 +121,6 @@ def __init__(
131121
# Save the credentials.
132122
self._credentials = credentials
133123

134-
# TODO(busunkim): This method is in the base transport
135-
# to avoid duplicating code across the transport classes. These functions
136-
# should be deleted once the minimum required versions of google-auth is increased.
137-
138-
# TODO: Remove this function once google-auth >= 1.25.0 is required
139-
@classmethod
140-
def _get_scopes_kwargs(
141-
cls, host: str, scopes: Optional[Sequence[str]]
142-
) -> Dict[str, Optional[Sequence[str]]]:
143-
"""Returns scopes kwargs to pass to google-auth methods depending on the google-auth version"""
144-
145-
scopes_kwargs = {}
146-
147-
if _GOOGLE_AUTH_VERSION and (
148-
packaging.version.parse(_GOOGLE_AUTH_VERSION)
149-
>= packaging.version.parse("1.25.0")
150-
):
151-
scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES}
152-
else:
153-
scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES}
154-
155-
return scopes_kwargs
156-
157124
def _prep_wrapped_messages(self, client_info):
158125
# Precompute the wrapped methods.
159126
self._wrapped_methods = {
@@ -229,7 +196,7 @@ def close(self):
229196
raise NotImplementedError()
230197

231198
@property
232-
def operations_client(self) -> operations_v1.OperationsClient:
199+
def operations_client(self):
233200
"""Return the client designed to process long-running operations."""
234201
raise NotImplementedError()
235202

packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/grpc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def __init__(
115115
self._grpc_channel = None
116116
self._ssl_channel_credentials = ssl_channel_credentials
117117
self._stubs: Dict[str, Callable] = {}
118-
self._operations_client = None
118+
self._operations_client: Optional[operations_v1.OperationsClient] = None
119119

120120
if api_mtls_endpoint:
121121
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)

packages/google-cloud-vision/google/cloud/vision_v1/services/image_annotator/transports/grpc_asyncio.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from google.api_core import operations_v1 # type: ignore
2222
from google.auth import credentials as ga_credentials # type: ignore
2323
from google.auth.transport.grpc import SslCredentials # type: ignore
24-
import packaging.version
2524

2625
import grpc # type: ignore
2726
from grpc.experimental import aio # type: ignore
@@ -162,7 +161,7 @@ def __init__(
162161
self._grpc_channel = None
163162
self._ssl_channel_credentials = ssl_channel_credentials
164163
self._stubs: Dict[str, Callable] = {}
165-
self._operations_client = None
164+
self._operations_client: Optional[operations_v1.OperationsAsyncClient] = None
166165

167166
if api_mtls_endpoint:
168167
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)

0 commit comments

Comments
 (0)