From 112049e79f5a5b0a989d85d438a1bd29485f46f7 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Tue, 15 Mar 2022 11:35:14 -0400 Subject: [PATCH 1/7] fix: allow grpc without grpcio-status (#355) --- google/api_core/exceptions.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/google/api_core/exceptions.py b/google/api_core/exceptions.py index 24b65ee0..38fe6e78 100644 --- a/google/api_core/exceptions.py +++ b/google/api_core/exceptions.py @@ -24,15 +24,23 @@ import http.client from typing import Dict from typing import Union +import warnings from google.rpc import error_details_pb2 try: import grpc - from grpc_status import rpc_status + + try: + from grpc_status import rpc_status + except ImportError: # pragma: NO COVER + warnings.warn( + "Please install grpcio-status to obtain helpful grpc error messages.", + ImportWarning, + ) + rpc_status = None except ImportError: # pragma: NO COVER grpc = None - rpc_status = None # Lookup tables for mapping exceptions from HTTP and gRPC transports. # Populated by _GoogleAPICallErrorMeta From 778d27d18ce17e7c0b6dbc1fb56ddf093e278a4e Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 30 Mar 2022 06:18:58 -0400 Subject: [PATCH 2/7] chore(python): use black==22.3.0 (#362) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(python): use black==22.3.0 Source-Link: https://github.com/googleapis/synthtool/commit/6fab84af09f2cf89a031fd8671d1def6b2931b11 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe * ci: use black 22.3.0 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot Co-authored-by: Anthonios Partheniou --- .github/.OwlBot.lock.yaml | 2 +- docs/conf.py | 13 +++- google/api_core/datetime_helpers.py | 4 +- google/api_core/exceptions.py | 6 +- google/api_core/grpc_helpers.py | 4 +- .../abstract_operations_client.py | 68 +++++++++++++++---- .../api_core/operations_v1/transports/base.py | 6 +- google/api_core/path_template.py | 40 +++++------ google/api_core/rest_streaming.py | 3 +- noxfile.py | 7 +- tests/asyncio/gapic/test_method_async.py | 3 +- .../test_operations_rest_client.py | 48 +++++++++---- tests/unit/test_client_options.py | 3 +- tests/unit/test_extended_operation.py | 4 +- tests/unit/test_page_iterator.py | 3 +- tests/unit/test_rest_streaming.py | 8 ++- 16 files changed, 152 insertions(+), 70 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 480226ac..87dd0061 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,4 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:6162c384d685c5fe22521d3f37f6fc732bf99a085f6d47b677dbcae97fc21392 + digest: sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe diff --git a/docs/conf.py b/docs/conf.py index 09f0c2b6..9a80171b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -314,7 +314,13 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (root_doc, "google-api-core", "google-api-core Documentation", [author], 1,) + ( + root_doc, + "google-api-core", + "google-api-core Documentation", + [author], + 1, + ) ] # If true, show URL addresses after external links. @@ -355,7 +361,10 @@ intersphinx_mapping = { "python": ("https://python.readthedocs.org/en/latest/", None), "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), + "google.api_core": ( + "https://googleapis.dev/python/google-api-core/latest/", + None, + ), "grpc": ("https://grpc.github.io/grpc/python/", None), "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), diff --git a/google/api_core/datetime_helpers.py b/google/api_core/datetime_helpers.py index 78268efc..9470863a 100644 --- a/google/api_core/datetime_helpers.py +++ b/google/api_core/datetime_helpers.py @@ -151,7 +151,7 @@ def from_rfc3339(value): micros = 0 else: scale = 9 - len(fraction) - nanos = int(fraction) * (10 ** scale) + nanos = int(fraction) * (10**scale) micros = nanos // 1000 return bare_seconds.replace(microsecond=micros, tzinfo=datetime.timezone.utc) @@ -245,7 +245,7 @@ def from_rfc3339(cls, stamp): nanos = 0 else: scale = 9 - len(fraction) - nanos = int(fraction) * (10 ** scale) + nanos = int(fraction) * (10**scale) return cls( bare.year, bare.month, diff --git a/google/api_core/exceptions.py b/google/api_core/exceptions.py index 38fe6e78..bd2f8562 100644 --- a/google/api_core/exceptions.py +++ b/google/api_core/exceptions.py @@ -202,7 +202,7 @@ def details(self): Returns: Sequence[Any]: A list of structured objects from error_details.proto - """ + """ return list(self._details) @property @@ -490,7 +490,9 @@ def from_http_response(response): error_info = error_info[0] if error_info else None message = "{method} {url}: {error}".format( - method=response.request.method, url=response.request.url, error=error_message, + method=response.request.method, + url=response.request.url, + error=error_message, ) exception = from_http_status( diff --git a/google/api_core/grpc_helpers.py b/google/api_core/grpc_helpers.py index 594df987..e86ddde5 100644 --- a/google/api_core/grpc_helpers.py +++ b/google/api_core/grpc_helpers.py @@ -246,7 +246,9 @@ def _create_composite_credentials( # Create the metadata plugin for inserting the authorization header. metadata_plugin = google.auth.transport.grpc.AuthMetadataPlugin( - credentials, request, default_host=default_host, + credentials, + request, + default_host=default_host, ) # Create a set of grpc.CallCredentials using the metadata plugin. diff --git a/google/api_core/operations_v1/abstract_operations_client.py b/google/api_core/operations_v1/abstract_operations_client.py index 631094e7..e02bc199 100644 --- a/google/api_core/operations_v1/abstract_operations_client.py +++ b/google/api_core/operations_v1/abstract_operations_client.py @@ -49,7 +49,8 @@ class AbstractOperationsClientMeta(type): _transport_registry["rest"] = OperationsRestTransport def get_transport_class( - cls, label: Optional[str] = None, + cls, + label: Optional[str] = None, ) -> Type[OperationsTransport]: """Returns an appropriate transport class. @@ -165,7 +166,9 @@ def transport(self) -> OperationsTransport: return self._transport @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -178,9 +181,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -189,9 +196,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -200,9 +211,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -211,10 +226,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -406,12 +425,20 @@ def list_operations( ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListOperationsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -459,7 +486,12 @@ def get_operation( ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -506,7 +538,10 @@ def delete_operation( # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def cancel_operation( @@ -560,5 +595,8 @@ def cancel_operation( # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) diff --git a/google/api_core/operations_v1/transports/base.py b/google/api_core/operations_v1/transports/base.py index 460e6460..f9070567 100644 --- a/google/api_core/operations_v1/transports/base.py +++ b/google/api_core/operations_v1/transports/base.py @@ -183,9 +183,9 @@ def _prep_wrapped_messages(self, client_info): def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() diff --git a/google/api_core/path_template.py b/google/api_core/path_template.py index b6284c85..a99a4c81 100644 --- a/google/api_core/path_template.py +++ b/google/api_core/path_template.py @@ -239,26 +239,26 @@ def validate(tmpl, path): def transcode(http_options, **request_kwargs): """Transcodes a grpc request pattern into a proper HTTP request following the rules outlined here, - https://github.com/googleapis/googleapis/blob/master/google/api/http.proto#L44-L312 - - Args: - http_options (list(dict)): A list of dicts which consist of these keys, - 'method' (str): The http method - 'uri' (str): The path template - 'body' (str): The body field name (optional) - (This is a simplified representation of the proto option `google.api.http`) - - request_kwargs (dict) : A dict representing the request object - - Returns: - dict: The transcoded request with these keys, - 'method' (str) : The http method - 'uri' (str) : The expanded uri - 'body' (dict) : A dict representing the body (optional) - 'query_params' (dict) : A dict mapping query parameter variables and values - - Raises: - ValueError: If the request does not match the given template. + https://github.com/googleapis/googleapis/blob/master/google/api/http.proto#L44-L312 + + Args: + http_options (list(dict)): A list of dicts which consist of these keys, + 'method' (str): The http method + 'uri' (str): The path template + 'body' (str): The body field name (optional) + (This is a simplified representation of the proto option `google.api.http`) + + request_kwargs (dict) : A dict representing the request object + + Returns: + dict: The transcoded request with these keys, + 'method' (str) : The http method + 'uri' (str) : The expanded uri + 'body' (dict) : A dict representing the body (optional) + 'query_params' (dict) : A dict mapping query parameter variables and values + + Raises: + ValueError: If the request does not match the given template. """ for http_option in http_options: request = {} diff --git a/google/api_core/rest_streaming.py b/google/api_core/rest_streaming.py index 69f5b41b..f91381c1 100644 --- a/google/api_core/rest_streaming.py +++ b/google/api_core/rest_streaming.py @@ -48,8 +48,7 @@ def __init__(self, response: requests.Response, response_message_cls): self._escape_next = False def cancel(self): - """Cancel existing streaming operation. - """ + """Cancel existing streaming operation.""" self._response.close() def _process_chunk(self, chunk: str): diff --git a/noxfile.py b/noxfile.py index e02a1280..c9333219 100644 --- a/noxfile.py +++ b/noxfile.py @@ -21,7 +21,7 @@ import nox # pytype: disable=import-error -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] # Black and flake8 clash on the syntax for ignoring flake8's F401 in this file. BLACK_EXCLUDES = ["--exclude", "^/google/api_core/operations_v1/__init__.py"] @@ -64,7 +64,10 @@ def lint(session): session.install("flake8", "flake8-import-order", BLACK_VERSION) session.install(".") session.run( - "black", "--check", *BLACK_EXCLUDES, *BLACK_PATHS, + "black", + "--check", + *BLACK_EXCLUDES, + *BLACK_PATHS, ) session.run("flake8", "google", "tests") diff --git a/tests/asyncio/gapic/test_method_async.py b/tests/asyncio/gapic/test_method_async.py index 1410747d..11847da7 100644 --- a/tests/asyncio/gapic/test_method_async.py +++ b/tests/asyncio/gapic/test_method_async.py @@ -162,7 +162,8 @@ async def test_wrap_method_with_default_retry_and_timeout_using_sentinel(unused_ ) result = await wrapped_method( - retry=gapic_v1.method_async.DEFAULT, timeout=gapic_v1.method_async.DEFAULT, + retry=gapic_v1.method_async.DEFAULT, + timeout=gapic_v1.method_async.DEFAULT, ) assert result == 42 diff --git a/tests/unit/operations_v1/test_operations_rest_client.py b/tests/unit/operations_v1/test_operations_rest_client.py index dddf6b71..625539e2 100644 --- a/tests/unit/operations_v1/test_operations_rest_client.py +++ b/tests/unit/operations_v1/test_operations_rest_client.py @@ -399,7 +399,9 @@ def test_operations_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options) @@ -513,10 +515,12 @@ def test_list_operations_rest_pager(): next_page_token="abc", ), operations_pb2.ListOperationsResponse( - operations=[], next_page_token="def", + operations=[], + next_page_token="def", ), operations_pb2.ListOperationsResponse( - operations=[operations_pb2.Operation()], next_page_token="ghi", + operations=[operations_pb2.Operation()], + next_page_token="ghi", ), operations_pb2.ListOperationsResponse( operations=[operations_pb2.Operation(), operations_pb2.Operation()], @@ -553,7 +557,9 @@ def test_get_operation_rest( with mock.patch.object(Session, "request") as req: # Designate an appropriate value for the returned response. return_value = operations_pb2.Operation( - name="operations/sample1", done=True, error=status_pb2.Status(code=411), + name="operations/sample1", + done=True, + error=status_pb2.Status(code=411), ) # Wrap the value into a proper Response obj @@ -679,7 +685,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): AbstractOperationsClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -698,7 +705,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): AbstractOperationsClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -765,7 +773,8 @@ def test_operations_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transports.OperationsTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -792,7 +801,9 @@ def test_operations_auth_adc(): adc.return_value = (ga_credentials.AnonymousCredentials(), None) AbstractOperationsClient() adc.assert_called_once_with( - scopes=None, default_scopes=(), quota_project_id=None, + scopes=None, + default_scopes=(), + quota_project_id=None, ) @@ -849,7 +860,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = AbstractOperationsClient.common_folder_path(folder) assert expected == actual @@ -867,7 +880,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = AbstractOperationsClient.common_organization_path(organization) assert expected == actual @@ -885,7 +900,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = AbstractOperationsClient.common_project_path(project) assert expected == actual @@ -905,7 +922,8 @@ def test_common_location_path(): project = "winkle" location = "nautilus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = AbstractOperationsClient.common_location_path(project, location) assert expected == actual @@ -930,7 +948,8 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.OperationsTransport, "_prep_wrapped_messages" ) as prep: AbstractOperationsClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -939,6 +958,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = AbstractOperationsClient.get_transport_class() transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) diff --git a/tests/unit/test_client_options.py b/tests/unit/test_client_options.py index fbff5457..334b8c1f 100644 --- a/tests/unit/test_client_options.py +++ b/tests/unit/test_client_options.py @@ -98,7 +98,8 @@ def test_constructor_with_api_key(): def test_constructor_with_both_api_key_and_credentials_file(): with pytest.raises(ValueError): client_options.ClientOptions( - api_key="api-key", credentials_file="path/to/credentials.json", + api_key="api-key", + credentials_file="path/to/credentials.json", ) diff --git a/tests/unit/test_extended_operation.py b/tests/unit/test_extended_operation.py index 9521fde8..ad62b778 100644 --- a/tests/unit/test_extended_operation.py +++ b/tests/unit/test_extended_operation.py @@ -59,7 +59,9 @@ def make_extended_operation(responses=None): refresh.responses = client_operations_responses cancel = mock.Mock(spec=["__call__"]) extended_operation_future = extended_operation.ExtendedOperation.make( - refresh, cancel, client_operations_responses[0], + refresh, + cancel, + client_operations_responses[0], ) return extended_operation_future, refresh, cancel diff --git a/tests/unit/test_page_iterator.py b/tests/unit/test_page_iterator.py index a44e998b..cf43aedf 100644 --- a/tests/unit/test_page_iterator.py +++ b/tests/unit/test_page_iterator.py @@ -505,7 +505,8 @@ def api_request(*args, **kw): assert list(next(items_iter)) == [ dict(name=str(i)) for i in range( - ipage * page_size, min((ipage + 1) * page_size, n_results), + ipage * page_size, + min((ipage + 1) * page_size, n_results), ) ] else: diff --git a/tests/unit/test_rest_streaming.py b/tests/unit/test_rest_streaming.py index 4be59580..1b34a04f 100644 --- a/tests/unit/test_rest_streaming.py +++ b/tests/unit/test_rest_streaming.py @@ -83,7 +83,10 @@ def __next__(self): return x.decode("utf-8") def __init__( - self, responses: List[proto.Message], response_cls, random_split=False, + self, + responses: List[proto.Message], + response_cls, + random_split=False, ): super().__init__() self._responses = responses @@ -105,7 +108,8 @@ def close(self): def iter_content(self, *args, **kwargs): return self._ResponseItr( - self._parse_responses(self._responses), random_split=self._random_split, + self._parse_responses(self._responses), + random_split=self._random_split, ) From 7186e36b72dafc821629455254999c914cdca43f Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 1 Apr 2022 00:12:27 +0000 Subject: [PATCH 3/7] chore(python): update .pre-commit-config.yaml to use black==22.3.0 (#363) Source-Link: https://github.com/googleapis/synthtool/commit/7804ade3daae0d66649bee8df6c55484c6580b8d Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:eede5672562a32821444a8e803fb984a6f61f2237ea3de229d2de24453f4ae7d --- .github/.OwlBot.lock.yaml | 3 ++- .pre-commit-config.yaml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 87dd0061..22cc254a 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe + digest: sha256:eede5672562a32821444a8e803fb984a6f61f2237ea3de229d2de24453f4ae7d +# created: 2022-03-30T23:44:26.560599165Z diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 62eb5a77..46d23716 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/psf/black - rev: 19.10b0 + rev: 22.3.0 hooks: - id: black - repo: https://gitlab.com/pycqa/flake8 From 45b0b52730938cdb77d3e99dc602d3dcf4917403 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 31 Mar 2022 21:59:34 -0400 Subject: [PATCH 4/7] chore(python): Enable size-label bot (#364) Source-Link: https://github.com/googleapis/synthtool/commit/06e82790dd719a165ad32b8a06f8f6ec3e3cae0f Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:b3500c053313dc34e07b1632ba9e4e589f4f77036a7cf39e1fe8906811ae0fce Co-authored-by: Owl Bot --- .github/.OwlBot.lock.yaml | 4 ++-- .github/auto-label.yaml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 .github/auto-label.yaml diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 22cc254a..58a0b153 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:eede5672562a32821444a8e803fb984a6f61f2237ea3de229d2de24453f4ae7d -# created: 2022-03-30T23:44:26.560599165Z + digest: sha256:b3500c053313dc34e07b1632ba9e4e589f4f77036a7cf39e1fe8906811ae0fce +# created: 2022-04-01T01:42:03.609279246Z diff --git a/.github/auto-label.yaml b/.github/auto-label.yaml new file mode 100644 index 00000000..09c8d735 --- /dev/null +++ b/.github/auto-label.yaml @@ -0,0 +1,2 @@ +requestsize: + enabled: true From caba5f22b35305531626bafc4e0041619208ca26 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 6 Apr 2022 06:44:25 -0400 Subject: [PATCH 5/7] chore(python): add license header to auto-label.yaml (#365) Source-Link: https://github.com/googleapis/synthtool/commit/eb78c980b52c7c6746d2edb77d9cf7aaa99a2aab Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:8a5d3f6a2e43ed8293f34e06a2f56931d1e88a2694c3bb11b15df4eb256ad163 Co-authored-by: Owl Bot --- .github/.OwlBot.lock.yaml | 4 ++-- .github/auto-label.yaml | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 58a0b153..bc893c97 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:b3500c053313dc34e07b1632ba9e4e589f4f77036a7cf39e1fe8906811ae0fce -# created: 2022-04-01T01:42:03.609279246Z + digest: sha256:8a5d3f6a2e43ed8293f34e06a2f56931d1e88a2694c3bb11b15df4eb256ad163 +# created: 2022-04-06T10:30:21.687684602Z diff --git a/.github/auto-label.yaml b/.github/auto-label.yaml index 09c8d735..41bff0b5 100644 --- a/.github/auto-label.yaml +++ b/.github/auto-label.yaml @@ -1,2 +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. requestsize: enabled: true From 523dbd0b10d37ffcf83fa751f0bad313f162abf1 Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Wed, 13 Apr 2022 12:22:14 -0400 Subject: [PATCH 6/7] fix: remove dependency on pkg_resources (#361) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #360 🦕 --- google/api_core/client_info.py | 8 ++++---- google/api_core/grpc_helpers.py | 9 --------- google/api_core/operations_v1/transports/base.py | 15 +++++---------- 3 files changed, 9 insertions(+), 23 deletions(-) diff --git a/google/api_core/client_info.py b/google/api_core/client_info.py index e093ffda..3e4376c9 100644 --- a/google/api_core/client_info.py +++ b/google/api_core/client_info.py @@ -21,8 +21,6 @@ import platform from typing import Union -import pkg_resources - from google.api_core import version as api_core_version _PY_VERSION = platform.python_version() @@ -31,8 +29,10 @@ _GRPC_VERSION: Union[str, None] try: - _GRPC_VERSION = pkg_resources.get_distribution("grpcio").version -except pkg_resources.DistributionNotFound: # pragma: NO COVER + import grpc + + _GRPC_VERSION = grpc.__version__ +except ImportError: # pragma: NO COVER _GRPC_VERSION = None diff --git a/google/api_core/grpc_helpers.py b/google/api_core/grpc_helpers.py index e86ddde5..db16f6fc 100644 --- a/google/api_core/grpc_helpers.py +++ b/google/api_core/grpc_helpers.py @@ -18,7 +18,6 @@ import functools import grpc -import pkg_resources from google.api_core import exceptions import google.auth @@ -33,14 +32,6 @@ except ImportError: HAS_GRPC_GCP = False -try: - # google.auth.__version__ was added in 1.26.0 - _GOOGLE_AUTH_VERSION = google.auth.__version__ -except AttributeError: - try: # try pkg_resources if it is available - _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version - except pkg_resources.DistributionNotFound: # pragma: NO COVER - _GOOGLE_AUTH_VERSION = None # The list of gRPC Callable interfaces that return iterators. _STREAM_WRAP_CLASSES = (grpc.UnaryStreamMultiCallable, grpc.StreamStreamMultiCallable) diff --git a/google/api_core/operations_v1/transports/base.py b/google/api_core/operations_v1/transports/base.py index f9070567..e19bc3e8 100644 --- a/google/api_core/operations_v1/transports/base.py +++ b/google/api_core/operations_v1/transports/base.py @@ -16,26 +16,21 @@ import abc from typing import Awaitable, Callable, Optional, Sequence, Union -import pkg_resources - import google.api_core # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore +from google.api_core import version import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.longrunning import operations_pb2 from google.oauth2 import service_account # type: ignore from google.protobuf import empty_pb2 # type: ignore -try: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution( - "google.api_core.operations_v1", - ).version, - ) -except pkg_resources.DistributionNotFound: - DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() + +DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( + gapic_version=version.__version__, +) class OperationsTransport(abc.ABC): From 319c02638682563edc1deb24c5e8ba28d15facab Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 13 Apr 2022 12:26:39 -0400 Subject: [PATCH 7/7] chore(main): release 2.7.2 (#358) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 8 ++++++++ google/api_core/version.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0610df01..5ac245f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ [1]: https://pypi.org/project/google-api-core/#history +### [2.7.2](https://github.com/googleapis/python-api-core/compare/v2.7.1...v2.7.2) (2022-04-13) + + +### Bug Fixes + +* allow grpc without grpcio-status ([#355](https://github.com/googleapis/python-api-core/issues/355)) ([112049e](https://github.com/googleapis/python-api-core/commit/112049e79f5a5b0a989d85d438a1bd29485f46f7)) +* remove dependency on pkg_resources ([#361](https://github.com/googleapis/python-api-core/issues/361)) ([523dbd0](https://github.com/googleapis/python-api-core/commit/523dbd0b10d37ffcf83fa751f0bad313f162abf1)) + ### [2.7.1](https://github.com/googleapis/python-api-core/compare/v2.7.0...v2.7.1) (2022-03-09) diff --git a/google/api_core/version.py b/google/api_core/version.py index a97caa56..52126b8e 100644 --- a/google/api_core/version.py +++ b/google/api_core/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "2.7.1" +__version__ = "2.7.2"