From 22388d565cd59c06e15aa1bdef329dc1b2ad9422 Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 28 Mar 2022 23:34:03 +0000 Subject: [PATCH] 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 --- .github/.OwlBot.lock.yaml | 2 +- docs/conf.py | 5 +- .../auto_suggestion_service/async_client.py | 11 +- .../auto_suggestion_service/client.py | 50 ++- .../transports/base.py | 14 +- .../transports/grpc.py | 3 +- .../services/question_service/async_client.py | 39 ++- .../services/question_service/client.py | 100 ++++-- .../question_service/transports/base.py | 26 +- .../question_service/transports/grpc.py | 3 +- .../dataqna_v1alpha/types/annotated_string.py | 35 ++- .../types/auto_suggestion_service.py | 64 +++- .../cloud/dataqna_v1alpha/types/question.py | 257 ++++++++++++--- .../dataqna_v1alpha/types/question_service.py | 45 ++- .../dataqna_v1alpha/types/user_feedback.py | 21 +- noxfile.py | 9 +- .../test_auto_suggestion_service.py | 88 ++++-- .../dataqna_v1alpha/test_question_service.py | 294 +++++++++++++----- 18 files changed, 824 insertions(+), 242 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 44c78f7..87dd006 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:4e1991042fe54b991db9ca17c8fb386e61b22fe4d1472a568bf0fcac85dcf5d3 + digest: sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe diff --git a/docs/conf.py b/docs/conf.py index 8ed8fc2..0bd5b3d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -361,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/cloud/dataqna_v1alpha/services/auto_suggestion_service/async_client.py b/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/async_client.py index 675420d..0926014 100644 --- a/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/async_client.py +++ b/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/async_client.py @@ -335,7 +335,12 @@ def sample_suggest_queries(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -349,7 +354,9 @@ async def __aexit__(self, exc_type, exc, tb): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-dataqna",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-dataqna", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/client.py b/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/client.py index e978cc6..e98b54a 100644 --- a/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/client.py +++ b/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/client.py @@ -55,7 +55,8 @@ class AutoSuggestionServiceClientMeta(type): _transport_registry["grpc_asyncio"] = AutoSuggestionServiceGrpcAsyncIOTransport def get_transport_class( - cls, label: str = None, + cls, + label: str = None, ) -> Type[AutoSuggestionServiceTransport]: """Returns an appropriate transport class. @@ -232,7 +233,9 @@ def transport(self) -> AutoSuggestionServiceTransport: 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, @@ -245,9 +248,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]: @@ -256,9 +263,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]: @@ -267,9 +278,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]: @@ -278,10 +293,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 @@ -518,7 +537,12 @@ def sample_suggest_queries(): ) # 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 @@ -539,7 +563,9 @@ def __exit__(self, type, value, traceback): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-dataqna",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-dataqna", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/base.py b/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/base.py index 8d4f914..23b6593 100644 --- a/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/base.py +++ b/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/base.py @@ -29,7 +29,9 @@ try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-dataqna",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-dataqna", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -119,16 +121,18 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.suggest_queries: gapic_v1.method.wrap_method( - self.suggest_queries, default_timeout=None, client_info=client_info, + self.suggest_queries, + default_timeout=None, + client_info=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/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/grpc.py b/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/grpc.py index caa5d91..503b086 100644 --- a/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/grpc.py +++ b/google/cloud/dataqna_v1alpha/services/auto_suggestion_service/transports/grpc.py @@ -294,8 +294,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property diff --git a/google/cloud/dataqna_v1alpha/services/question_service/async_client.py b/google/cloud/dataqna_v1alpha/services/question_service/async_client.py index 214492e..51d0921 100644 --- a/google/cloud/dataqna_v1alpha/services/question_service/async_client.py +++ b/google/cloud/dataqna_v1alpha/services/question_service/async_client.py @@ -317,7 +317,12 @@ def sample_get_question(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -424,7 +429,12 @@ def sample_create_question(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -528,7 +538,12 @@ def sample_execute_question(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -617,7 +632,12 @@ def sample_get_user_feedback(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -723,7 +743,12 @@ def sample_update_user_feedback(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -737,7 +762,9 @@ async def __aexit__(self, exc_type, exc, tb): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-dataqna",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-dataqna", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/dataqna_v1alpha/services/question_service/client.py b/google/cloud/dataqna_v1alpha/services/question_service/client.py index fc0f5c0..708a5e1 100644 --- a/google/cloud/dataqna_v1alpha/services/question_service/client.py +++ b/google/cloud/dataqna_v1alpha/services/question_service/client.py @@ -61,7 +61,10 @@ class QuestionServiceClientMeta(type): _transport_registry["grpc"] = QuestionServiceGrpcTransport _transport_registry["grpc_asyncio"] = QuestionServiceGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[QuestionServiceTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[QuestionServiceTransport]: """Returns an appropriate transport class. Args: @@ -183,10 +186,16 @@ def transport(self) -> QuestionServiceTransport: return self._transport @staticmethod - def question_path(project: str, location: str, question: str,) -> str: + def question_path( + project: str, + location: str, + question: str, + ) -> str: """Returns a fully-qualified question string.""" return "projects/{project}/locations/{location}/questions/{question}".format( - project=project, location=location, question=question, + project=project, + location=location, + question=question, ) @staticmethod @@ -199,10 +208,16 @@ def parse_question_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def user_feedback_path(project: str, location: str, question: str,) -> str: + def user_feedback_path( + project: str, + location: str, + question: str, + ) -> str: """Returns a fully-qualified user_feedback string.""" return "projects/{project}/locations/{location}/questions/{question}/userFeedback".format( - project=project, location=location, question=question, + project=project, + location=location, + question=question, ) @staticmethod @@ -215,7 +230,9 @@ def parse_user_feedback_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @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, @@ -228,9 +245,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]: @@ -239,9 +260,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]: @@ -250,9 +275,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]: @@ -261,10 +290,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 @@ -526,7 +559,12 @@ def sample_get_question(): ) # 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 @@ -633,7 +671,12 @@ def sample_create_question(): ) # 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 @@ -737,7 +780,12 @@ def sample_execute_question(): ) # 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 @@ -826,7 +874,12 @@ def sample_get_user_feedback(): ) # 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 @@ -932,7 +985,12 @@ def sample_update_user_feedback(): ) # 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 @@ -953,7 +1011,9 @@ def __exit__(self, type, value, traceback): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-dataqna",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-dataqna", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/dataqna_v1alpha/services/question_service/transports/base.py b/google/cloud/dataqna_v1alpha/services/question_service/transports/base.py index 2c4c790..a4f67ec 100644 --- a/google/cloud/dataqna_v1alpha/services/question_service/transports/base.py +++ b/google/cloud/dataqna_v1alpha/services/question_service/transports/base.py @@ -33,7 +33,9 @@ try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-dataqna",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-dataqna", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -123,16 +125,24 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.get_question: gapic_v1.method.wrap_method( - self.get_question, default_timeout=None, client_info=client_info, + self.get_question, + default_timeout=None, + client_info=client_info, ), self.create_question: gapic_v1.method.wrap_method( - self.create_question, default_timeout=60.0, client_info=client_info, + self.create_question, + default_timeout=60.0, + client_info=client_info, ), self.execute_question: gapic_v1.method.wrap_method( - self.execute_question, default_timeout=60.0, client_info=client_info, + self.execute_question, + default_timeout=60.0, + client_info=client_info, ), self.get_user_feedback: gapic_v1.method.wrap_method( - self.get_user_feedback, default_timeout=None, client_info=client_info, + self.get_user_feedback, + default_timeout=None, + client_info=client_info, ), self.update_user_feedback: gapic_v1.method.wrap_method( self.update_user_feedback, @@ -144,9 +154,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/cloud/dataqna_v1alpha/services/question_service/transports/grpc.py b/google/cloud/dataqna_v1alpha/services/question_service/transports/grpc.py index 0eb6998..7386a6b 100644 --- a/google/cloud/dataqna_v1alpha/services/question_service/transports/grpc.py +++ b/google/cloud/dataqna_v1alpha/services/question_service/transports/grpc.py @@ -244,8 +244,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property diff --git a/google/cloud/dataqna_v1alpha/types/annotated_string.py b/google/cloud/dataqna_v1alpha/types/annotated_string.py index 753d86e..a3574a9 100644 --- a/google/cloud/dataqna_v1alpha/types/annotated_string.py +++ b/google/cloud/dataqna_v1alpha/types/annotated_string.py @@ -17,7 +17,10 @@ __protobuf__ = proto.module( - package="google.cloud.dataqna.v1alpha", manifest={"AnnotatedString",}, + package="google.cloud.dataqna.v1alpha", + manifest={ + "AnnotatedString", + }, ) @@ -87,14 +90,32 @@ class SemanticMarkup(proto.Message): """ type_ = proto.Field( - proto.ENUM, number=1, enum="AnnotatedString.SemanticMarkupType", + proto.ENUM, + number=1, + enum="AnnotatedString.SemanticMarkupType", + ) + start_char_index = proto.Field( + proto.INT32, + number=2, + ) + length = proto.Field( + proto.INT32, + number=3, ) - start_char_index = proto.Field(proto.INT32, number=2,) - length = proto.Field(proto.INT32, number=3,) - text_formatted = proto.Field(proto.STRING, number=1,) - html_formatted = proto.Field(proto.STRING, number=2,) - markups = proto.RepeatedField(proto.MESSAGE, number=3, message=SemanticMarkup,) + text_formatted = proto.Field( + proto.STRING, + number=1, + ) + html_formatted = proto.Field( + proto.STRING, + number=2, + ) + markups = proto.RepeatedField( + proto.MESSAGE, + number=3, + message=SemanticMarkup, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/dataqna_v1alpha/types/auto_suggestion_service.py b/google/cloud/dataqna_v1alpha/types/auto_suggestion_service.py index 05d11db..e222cb9 100644 --- a/google/cloud/dataqna_v1alpha/types/auto_suggestion_service.py +++ b/google/cloud/dataqna_v1alpha/types/auto_suggestion_service.py @@ -65,10 +65,23 @@ class SuggestQueriesRequest(proto.Message): cut these suggestions off. """ - parent = proto.Field(proto.STRING, number=1,) - scopes = proto.RepeatedField(proto.STRING, number=2,) - query = proto.Field(proto.STRING, number=3,) - suggestion_types = proto.RepeatedField(proto.ENUM, number=4, enum="SuggestionType",) + parent = proto.Field( + proto.STRING, + number=1, + ) + scopes = proto.RepeatedField( + proto.STRING, + number=2, + ) + query = proto.Field( + proto.STRING, + number=3, + ) + suggestion_types = proto.RepeatedField( + proto.ENUM, + number=4, + enum="SuggestionType", + ) class Suggestion(proto.Message): @@ -86,9 +99,20 @@ class Suggestion(proto.Message): The type of the suggestion. """ - suggestion_info = proto.Field(proto.MESSAGE, number=1, message="SuggestionInfo",) - ranking_score = proto.Field(proto.DOUBLE, number=2,) - suggestion_type = proto.Field(proto.ENUM, number=3, enum="SuggestionType",) + suggestion_info = proto.Field( + proto.MESSAGE, + number=1, + message="SuggestionInfo", + ) + ranking_score = proto.Field( + proto.DOUBLE, + number=2, + ) + suggestion_type = proto.Field( + proto.ENUM, + number=3, + enum="SuggestionType", + ) class SuggestionInfo(proto.Message): @@ -140,13 +164,25 @@ class MatchInfo(proto.Message): substring. """ - start_char_index = proto.Field(proto.INT32, number=1,) - length = proto.Field(proto.INT32, number=2,) + start_char_index = proto.Field( + proto.INT32, + number=1, + ) + length = proto.Field( + proto.INT32, + number=2, + ) annotated_suggestion = proto.Field( - proto.MESSAGE, number=1, message=annotated_string.AnnotatedString, + proto.MESSAGE, + number=1, + message=annotated_string.AnnotatedString, + ) + query_matches = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=MatchInfo, ) - query_matches = proto.RepeatedField(proto.MESSAGE, number=2, message=MatchInfo,) class SuggestQueriesResponse(proto.Message): @@ -157,7 +193,11 @@ class SuggestQueriesResponse(proto.Message): A list of suggestions. """ - suggestions = proto.RepeatedField(proto.MESSAGE, number=1, message="Suggestion",) + suggestions = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Suggestion", + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/dataqna_v1alpha/types/question.py b/google/cloud/dataqna_v1alpha/types/question.py index 1f70933..80f1090 100644 --- a/google/cloud/dataqna_v1alpha/types/question.py +++ b/google/cloud/dataqna_v1alpha/types/question.py @@ -102,18 +102,51 @@ class Question(proto.Message): message. """ - name = proto.Field(proto.STRING, number=1,) - scopes = proto.RepeatedField(proto.STRING, number=2,) - query = proto.Field(proto.STRING, number=3,) - data_source_annotations = proto.RepeatedField(proto.STRING, number=4,) - interpret_error = proto.Field(proto.MESSAGE, number=5, message="InterpretError",) + name = proto.Field( + proto.STRING, + number=1, + ) + scopes = proto.RepeatedField( + proto.STRING, + number=2, + ) + query = proto.Field( + proto.STRING, + number=3, + ) + data_source_annotations = proto.RepeatedField( + proto.STRING, + number=4, + ) + interpret_error = proto.Field( + proto.MESSAGE, + number=5, + message="InterpretError", + ) interpretations = proto.RepeatedField( - proto.MESSAGE, number=6, message="Interpretation", + proto.MESSAGE, + number=6, + message="Interpretation", + ) + create_time = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + user_email = proto.Field( + proto.STRING, + number=8, + ) + debug_flags = proto.Field( + proto.MESSAGE, + number=9, + message="DebugFlags", + ) + debug_info = proto.Field( + proto.MESSAGE, + number=10, + message=any_pb2.Any, ) - create_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) - user_email = proto.Field(proto.STRING, number=8,) - debug_flags = proto.Field(proto.MESSAGE, number=9, message="DebugFlags",) - debug_info = proto.Field(proto.MESSAGE, number=10, message=any_pb2.Any,) class InterpretError(proto.Message): @@ -163,7 +196,9 @@ class InterpretErrorDetails(proto.Message): message="InterpretError.InterpretIncompleteQueryDetails", ) ambiguity_details = proto.Field( - proto.MESSAGE, number=3, message="InterpretError.InterpretAmbiguityDetails", + proto.MESSAGE, + number=3, + message="InterpretError.InterpretAmbiguityDetails", ) class InterpretUnsupportedDetails(proto.Message): @@ -176,8 +211,14 @@ class InterpretUnsupportedDetails(proto.Message): Unsupported intents. """ - operators = proto.RepeatedField(proto.STRING, number=1,) - intent = proto.RepeatedField(proto.STRING, number=2,) + operators = proto.RepeatedField( + proto.STRING, + number=1, + ) + intent = proto.RepeatedField( + proto.STRING, + number=2, + ) class InterpretIncompleteQueryDetails(proto.Message): r"""Details about an incomplete query. @@ -187,7 +228,11 @@ class InterpretIncompleteQueryDetails(proto.Message): List of missing interpret entities. """ - entities = proto.RepeatedField(proto.ENUM, number=1, enum="InterpretEntity",) + entities = proto.RepeatedField( + proto.ENUM, + number=1, + enum="InterpretEntity", + ) class InterpretAmbiguityDetails(proto.Message): r"""Details about a query that was too ambiguous. Currently, the @@ -196,9 +241,20 @@ class InterpretAmbiguityDetails(proto.Message): """ - message = proto.Field(proto.STRING, number=1,) - code = proto.Field(proto.ENUM, number=2, enum=InterpretErrorCode,) - details = proto.Field(proto.MESSAGE, number=3, message=InterpretErrorDetails,) + message = proto.Field( + proto.STRING, + number=1, + ) + code = proto.Field( + proto.ENUM, + number=2, + enum=InterpretErrorCode, + ) + details = proto.Field( + proto.MESSAGE, + number=3, + message=InterpretErrorDetails, + ) class ExecutionInfo(proto.Message): @@ -229,11 +285,25 @@ class JobExecutionState(proto.Enum): FAILED = 4 job_creation_status = proto.Field( - proto.MESSAGE, number=1, message=status_pb2.Status, + proto.MESSAGE, + number=1, + message=status_pb2.Status, + ) + job_execution_state = proto.Field( + proto.ENUM, + number=2, + enum=JobExecutionState, + ) + create_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + bigquery_job = proto.Field( + proto.MESSAGE, + number=4, + message="BigQueryJob", ) - job_execution_state = proto.Field(proto.ENUM, number=2, enum=JobExecutionState,) - create_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) - bigquery_job = proto.Field(proto.MESSAGE, number=4, message="BigQueryJob",) class BigQueryJob(proto.Message): @@ -250,9 +320,18 @@ class BigQueryJob(proto.Message): The location where the job is running. """ - job_id = proto.Field(proto.STRING, number=1,) - project_id = proto.Field(proto.STRING, number=2,) - location = proto.Field(proto.STRING, number=3,) + job_id = proto.Field( + proto.STRING, + number=1, + ) + project_id = proto.Field( + proto.STRING, + number=2, + ) + location = proto.Field( + proto.STRING, + number=3, + ) class Interpretation(proto.Message): @@ -286,15 +365,38 @@ class Interpretation(proto.Message): interpretation was requested. """ - data_sources = proto.RepeatedField(proto.STRING, number=1,) - confidence = proto.Field(proto.DOUBLE, number=2,) - unused_phrases = proto.RepeatedField(proto.STRING, number=3,) - human_readable = proto.Field(proto.MESSAGE, number=4, message="HumanReadable",) + data_sources = proto.RepeatedField( + proto.STRING, + number=1, + ) + confidence = proto.Field( + proto.DOUBLE, + number=2, + ) + unused_phrases = proto.RepeatedField( + proto.STRING, + number=3, + ) + human_readable = proto.Field( + proto.MESSAGE, + number=4, + message="HumanReadable", + ) interpretation_structure = proto.Field( - proto.MESSAGE, number=5, message="InterpretationStructure", + proto.MESSAGE, + number=5, + message="InterpretationStructure", + ) + data_query = proto.Field( + proto.MESSAGE, + number=6, + message="DataQuery", + ) + execution_info = proto.Field( + proto.MESSAGE, + number=7, + message="ExecutionInfo", ) - data_query = proto.Field(proto.MESSAGE, number=6, message="DataQuery",) - execution_info = proto.Field(proto.MESSAGE, number=7, message="ExecutionInfo",) class DataQuery(proto.Message): @@ -311,7 +413,10 @@ class DataQuery(proto.Message): backend. """ - sql = proto.Field(proto.STRING, number=1,) + sql = proto.Field( + proto.STRING, + number=1, + ) class HumanReadable(proto.Message): @@ -326,10 +431,14 @@ class HumanReadable(proto.Message): """ generated_interpretation = proto.Field( - proto.MESSAGE, number=1, message=annotated_string.AnnotatedString, + proto.MESSAGE, + number=1, + message=annotated_string.AnnotatedString, ) original_question = proto.Field( - proto.MESSAGE, number=2, message=annotated_string.AnnotatedString, + proto.MESSAGE, + number=2, + message=annotated_string.AnnotatedString, ) @@ -379,13 +488,25 @@ class ColumnInfo(proto.Message): Human readable name of the output column. """ - output_alias = proto.Field(proto.STRING, number=1,) - display_name = proto.Field(proto.STRING, number=2,) + output_alias = proto.Field( + proto.STRING, + number=1, + ) + display_name = proto.Field( + proto.STRING, + number=2, + ) visualization_types = proto.RepeatedField( - proto.ENUM, number=1, enum=VisualizationType, + proto.ENUM, + number=1, + enum=VisualizationType, + ) + column_info = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=ColumnInfo, ) - column_info = proto.RepeatedField(proto.MESSAGE, number=2, message=ColumnInfo,) class DebugFlags(proto.Message): @@ -431,18 +552,54 @@ class DebugFlags(proto.Message): Whether to include the domain list. """ - include_va_query = proto.Field(proto.BOOL, number=1,) - include_nested_va_query = proto.Field(proto.BOOL, number=2,) - include_human_interpretation = proto.Field(proto.BOOL, number=3,) - include_aqua_debug_response = proto.Field(proto.BOOL, number=4,) - time_override = proto.Field(proto.INT64, number=5,) - is_internal_google_user = proto.Field(proto.BOOL, number=6,) - ignore_cache = proto.Field(proto.BOOL, number=7,) - include_search_entities_rpc = proto.Field(proto.BOOL, number=8,) - include_list_column_annotations_rpc = proto.Field(proto.BOOL, number=9,) - include_virtual_analyst_entities = proto.Field(proto.BOOL, number=10,) - include_table_list = proto.Field(proto.BOOL, number=11,) - include_domain_list = proto.Field(proto.BOOL, number=12,) + include_va_query = proto.Field( + proto.BOOL, + number=1, + ) + include_nested_va_query = proto.Field( + proto.BOOL, + number=2, + ) + include_human_interpretation = proto.Field( + proto.BOOL, + number=3, + ) + include_aqua_debug_response = proto.Field( + proto.BOOL, + number=4, + ) + time_override = proto.Field( + proto.INT64, + number=5, + ) + is_internal_google_user = proto.Field( + proto.BOOL, + number=6, + ) + ignore_cache = proto.Field( + proto.BOOL, + number=7, + ) + include_search_entities_rpc = proto.Field( + proto.BOOL, + number=8, + ) + include_list_column_annotations_rpc = proto.Field( + proto.BOOL, + number=9, + ) + include_virtual_analyst_entities = proto.Field( + proto.BOOL, + number=10, + ) + include_table_list = proto.Field( + proto.BOOL, + number=11, + ) + include_domain_list = proto.Field( + proto.BOOL, + number=12, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/dataqna_v1alpha/types/question_service.py b/google/cloud/dataqna_v1alpha/types/question_service.py index da1f0b7..354b3d7 100644 --- a/google/cloud/dataqna_v1alpha/types/question_service.py +++ b/google/cloud/dataqna_v1alpha/types/question_service.py @@ -43,8 +43,15 @@ class GetQuestionRequest(proto.Message): The list of fields to be retrieved. """ - name = proto.Field(proto.STRING, number=1,) - read_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask,) + name = proto.Field( + proto.STRING, + number=1, + ) + read_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) class CreateQuestionRequest(proto.Message): @@ -58,8 +65,15 @@ class CreateQuestionRequest(proto.Message): Required. The question to create. """ - parent = proto.Field(proto.STRING, number=1,) - question = proto.Field(proto.MESSAGE, number=2, message=gcd_question.Question,) + parent = proto.Field( + proto.STRING, + number=1, + ) + question = proto.Field( + proto.MESSAGE, + number=2, + message=gcd_question.Question, + ) class ExecuteQuestionRequest(proto.Message): @@ -74,8 +88,14 @@ class ExecuteQuestionRequest(proto.Message): execute. """ - name = proto.Field(proto.STRING, number=1,) - interpretation_index = proto.Field(proto.INT32, number=2,) + name = proto.Field( + proto.STRING, + number=1, + ) + interpretation_index = proto.Field( + proto.INT32, + number=2, + ) class GetUserFeedbackRequest(proto.Message): @@ -88,7 +108,10 @@ class GetUserFeedbackRequest(proto.Message): ``projects/foo/locations/bar/questions/1234/userFeedback`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class UpdateUserFeedbackRequest(proto.Message): @@ -106,10 +129,14 @@ class UpdateUserFeedbackRequest(proto.Message): """ user_feedback = proto.Field( - proto.MESSAGE, number=1, message=gcd_user_feedback.UserFeedback, + proto.MESSAGE, + number=1, + message=gcd_user_feedback.UserFeedback, ) update_mask = proto.Field( - proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, ) diff --git a/google/cloud/dataqna_v1alpha/types/user_feedback.py b/google/cloud/dataqna_v1alpha/types/user_feedback.py index cb99cb4..4176566 100644 --- a/google/cloud/dataqna_v1alpha/types/user_feedback.py +++ b/google/cloud/dataqna_v1alpha/types/user_feedback.py @@ -17,7 +17,10 @@ __protobuf__ = proto.module( - package="google.cloud.dataqna.v1alpha", manifest={"UserFeedback",}, + package="google.cloud.dataqna.v1alpha", + manifest={ + "UserFeedback", + }, ) @@ -41,9 +44,19 @@ class UserFeedbackRating(proto.Enum): POSITIVE = 1 NEGATIVE = 2 - name = proto.Field(proto.STRING, number=1,) - free_form_feedback = proto.Field(proto.STRING, number=2,) - rating = proto.Field(proto.ENUM, number=3, enum=UserFeedbackRating,) + name = proto.Field( + proto.STRING, + number=1, + ) + free_form_feedback = proto.Field( + proto.STRING, + number=2, + ) + rating = proto.Field( + proto.ENUM, + number=3, + enum=UserFeedbackRating, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/noxfile.py b/noxfile.py index 2a2001c..3addb4e 100644 --- a/noxfile.py +++ b/noxfile.py @@ -24,7 +24,7 @@ import nox -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" @@ -57,7 +57,9 @@ def lint(session): """ session.install("flake8", BLACK_VERSION) session.run( - "black", "--check", *BLACK_PATHS, + "black", + "--check", + *BLACK_PATHS, ) session.run("flake8", "google", "tests") @@ -67,7 +69,8 @@ def blacken(session): """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) session.run( - "black", *BLACK_PATHS, + "black", + *BLACK_PATHS, ) diff --git a/tests/unit/gapic/dataqna_v1alpha/test_auto_suggestion_service.py b/tests/unit/gapic/dataqna_v1alpha/test_auto_suggestion_service.py index ce664c5..c8f29e1 100644 --- a/tests/unit/gapic/dataqna_v1alpha/test_auto_suggestion_service.py +++ b/tests/unit/gapic/dataqna_v1alpha/test_auto_suggestion_service.py @@ -89,7 +89,11 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", [AutoSuggestionServiceClient, AutoSuggestionServiceAsyncClient,] + "client_class", + [ + AutoSuggestionServiceClient, + AutoSuggestionServiceAsyncClient, + ], ) def test_auto_suggestion_service_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() @@ -131,7 +135,11 @@ def test_auto_suggestion_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", [AutoSuggestionServiceClient, AutoSuggestionServiceAsyncClient,] + "client_class", + [ + AutoSuggestionServiceClient, + AutoSuggestionServiceAsyncClient, + ], ) def test_auto_suggestion_service_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() @@ -513,7 +521,9 @@ def test_auto_suggestion_service_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, transport=transport_name) @@ -654,11 +664,16 @@ def test_auto_suggestion_service_client_create_channel_credentials_file( @pytest.mark.parametrize( - "request_type", [auto_suggestion_service.SuggestQueriesRequest, dict,] + "request_type", + [ + auto_suggestion_service.SuggestQueriesRequest, + dict, + ], ) def test_suggest_queries(request_type, transport: str = "grpc"): client = AutoSuggestionServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -684,7 +699,8 @@ def test_suggest_queries_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = AutoSuggestionServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -701,7 +717,8 @@ async def test_suggest_queries_async( request_type=auto_suggestion_service.SuggestQueriesRequest, ): client = AutoSuggestionServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -753,7 +770,10 @@ def test_suggest_queries_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -782,7 +802,10 @@ async def test_suggest_queries_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_credentials_transport_error(): @@ -792,7 +815,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = AutoSuggestionServiceClient( - 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. @@ -813,7 +837,8 @@ def test_credentials_transport_error(): options.api_key = "api_key" with pytest.raises(ValueError): client = AutoSuggestionServiceClient( - client_options=options, transport=transport, + client_options=options, + transport=transport, ) # It is an error to provide an api_key and a credential. @@ -830,7 +855,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = AutoSuggestionServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -878,7 +904,10 @@ def test_transport_grpc_default(): client = AutoSuggestionServiceClient( credentials=ga_credentials.AnonymousCredentials(), ) - assert isinstance(client.transport, transports.AutoSuggestionServiceGrpcTransport,) + assert isinstance( + client.transport, + transports.AutoSuggestionServiceGrpcTransport, + ) def test_auto_suggestion_service_base_transport_error(): @@ -921,7 +950,8 @@ def test_auto_suggestion_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.AutoSuggestionServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -1083,7 +1113,8 @@ def test_auto_suggestion_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.AutoSuggestionServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1095,7 +1126,8 @@ def test_auto_suggestion_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.AutoSuggestionServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1224,7 +1256,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 = AutoSuggestionServiceClient.common_folder_path(folder) assert expected == actual @@ -1242,7 +1276,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 = AutoSuggestionServiceClient.common_organization_path(organization) assert expected == actual @@ -1260,7 +1296,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 = AutoSuggestionServiceClient.common_project_path(project) assert expected == actual @@ -1280,7 +1318,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 = AutoSuggestionServiceClient.common_location_path(project, location) assert expected == actual @@ -1305,7 +1344,8 @@ def test_client_with_default_client_info(): transports.AutoSuggestionServiceTransport, "_prep_wrapped_messages" ) as prep: client = AutoSuggestionServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1314,7 +1354,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = AutoSuggestionServiceClient.get_transport_class() transport = 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) @@ -1322,7 +1363,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = AutoSuggestionServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/dataqna_v1alpha/test_question_service.py b/tests/unit/gapic/dataqna_v1alpha/test_question_service.py index e1d9ae6..b15e5a8 100644 --- a/tests/unit/gapic/dataqna_v1alpha/test_question_service.py +++ b/tests/unit/gapic/dataqna_v1alpha/test_question_service.py @@ -95,7 +95,11 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", [QuestionServiceClient, QuestionServiceAsyncClient,] + "client_class", + [ + QuestionServiceClient, + QuestionServiceAsyncClient, + ], ) def test_question_service_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() @@ -137,7 +141,11 @@ def test_question_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", [QuestionServiceClient, QuestionServiceAsyncClient,] + "client_class", + [ + QuestionServiceClient, + QuestionServiceAsyncClient, + ], ) def test_question_service_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() @@ -511,7 +519,9 @@ def test_question_service_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, transport=transport_name) @@ -651,10 +661,17 @@ def test_question_service_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [question_service.GetQuestionRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + question_service.GetQuestionRequest, + dict, + ], +) def test_get_question(request_type, transport: str = "grpc"): client = QuestionServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -691,7 +708,8 @@ def test_get_question_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = QuestionServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -707,7 +725,8 @@ async def test_get_question_async( transport: str = "grpc_asyncio", request_type=question_service.GetQuestionRequest ): client = QuestionServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -748,7 +767,9 @@ async def test_get_question_async_from_dict(): def test_get_question_field_headers(): - client = QuestionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = QuestionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -768,7 +789,10 @@ def test_get_question_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -795,11 +819,16 @@ async def test_get_question_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_get_question_flattened(): - client = QuestionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = QuestionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_question), "__call__") as call: @@ -807,7 +836,9 @@ def test_get_question_flattened(): call.return_value = question.Question() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_question(name="name_value",) + client.get_question( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -819,13 +850,16 @@ def test_get_question_flattened(): def test_get_question_flattened_error(): - client = QuestionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = QuestionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_question( - question_service.GetQuestionRequest(), name="name_value", + question_service.GetQuestionRequest(), + name="name_value", ) @@ -843,7 +877,9 @@ async def test_get_question_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(question.Question()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_question(name="name_value",) + response = await client.get_question( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -864,16 +900,22 @@ async def test_get_question_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_question( - question_service.GetQuestionRequest(), name="name_value", + question_service.GetQuestionRequest(), + name="name_value", ) @pytest.mark.parametrize( - "request_type", [question_service.CreateQuestionRequest, dict,] + "request_type", + [ + question_service.CreateQuestionRequest, + dict, + ], ) def test_create_question(request_type, transport: str = "grpc"): client = QuestionServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -910,7 +952,8 @@ def test_create_question_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = QuestionServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -926,7 +969,8 @@ async def test_create_question_async( transport: str = "grpc_asyncio", request_type=question_service.CreateQuestionRequest ): client = QuestionServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -967,7 +1011,9 @@ async def test_create_question_async_from_dict(): def test_create_question_field_headers(): - client = QuestionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = QuestionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -987,7 +1033,10 @@ def test_create_question_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1016,11 +1065,16 @@ async def test_create_question_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_create_question_flattened(): - client = QuestionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = QuestionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_question), "__call__") as call: @@ -1029,7 +1083,8 @@ def test_create_question_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_question( - parent="parent_value", question=gcd_question.Question(name="name_value"), + parent="parent_value", + question=gcd_question.Question(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -1045,7 +1100,9 @@ def test_create_question_flattened(): def test_create_question_flattened_error(): - client = QuestionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = QuestionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1074,7 +1131,8 @@ async def test_create_question_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.create_question( - parent="parent_value", question=gcd_question.Question(name="name_value"), + parent="parent_value", + question=gcd_question.Question(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -1106,11 +1164,16 @@ async def test_create_question_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [question_service.ExecuteQuestionRequest, dict,] + "request_type", + [ + question_service.ExecuteQuestionRequest, + dict, + ], ) def test_execute_question(request_type, transport: str = "grpc"): client = QuestionServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1147,7 +1210,8 @@ def test_execute_question_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = QuestionServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1164,7 +1228,8 @@ async def test_execute_question_async( request_type=question_service.ExecuteQuestionRequest, ): client = QuestionServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1205,7 +1270,9 @@ async def test_execute_question_async_from_dict(): def test_execute_question_field_headers(): - client = QuestionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = QuestionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1225,7 +1292,10 @@ def test_execute_question_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1252,11 +1322,16 @@ async def test_execute_question_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_execute_question_flattened(): - client = QuestionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = QuestionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.execute_question), "__call__") as call: @@ -1265,7 +1340,8 @@ def test_execute_question_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.execute_question( - name="name_value", interpretation_index=2159, + name="name_value", + interpretation_index=2159, ) # Establish that the underlying call was made with the expected @@ -1281,7 +1357,9 @@ def test_execute_question_flattened(): def test_execute_question_flattened_error(): - client = QuestionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = QuestionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1308,7 +1386,8 @@ async def test_execute_question_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.execute_question( - name="name_value", interpretation_index=2159, + name="name_value", + interpretation_index=2159, ) # Establish that the underlying call was made with the expected @@ -1340,11 +1419,16 @@ async def test_execute_question_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [question_service.GetUserFeedbackRequest, dict,] + "request_type", + [ + question_service.GetUserFeedbackRequest, + dict, + ], ) def test_get_user_feedback(request_type, transport: str = "grpc"): client = QuestionServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1379,7 +1463,8 @@ def test_get_user_feedback_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = QuestionServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1398,7 +1483,8 @@ async def test_get_user_feedback_async( request_type=question_service.GetUserFeedbackRequest, ): client = QuestionServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1437,7 +1523,9 @@ async def test_get_user_feedback_async_from_dict(): def test_get_user_feedback_field_headers(): - client = QuestionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = QuestionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1459,7 +1547,10 @@ def test_get_user_feedback_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1490,11 +1581,16 @@ async def test_get_user_feedback_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_get_user_feedback_flattened(): - client = QuestionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = QuestionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1504,7 +1600,9 @@ def test_get_user_feedback_flattened(): call.return_value = user_feedback.UserFeedback() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_user_feedback(name="name_value",) + client.get_user_feedback( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1516,13 +1614,16 @@ def test_get_user_feedback_flattened(): def test_get_user_feedback_flattened_error(): - client = QuestionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = QuestionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_user_feedback( - question_service.GetUserFeedbackRequest(), name="name_value", + question_service.GetUserFeedbackRequest(), + name="name_value", ) @@ -1544,7 +1645,9 @@ async def test_get_user_feedback_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_user_feedback(name="name_value",) + response = await client.get_user_feedback( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1565,16 +1668,22 @@ async def test_get_user_feedback_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_user_feedback( - question_service.GetUserFeedbackRequest(), name="name_value", + question_service.GetUserFeedbackRequest(), + name="name_value", ) @pytest.mark.parametrize( - "request_type", [question_service.UpdateUserFeedbackRequest, dict,] + "request_type", + [ + question_service.UpdateUserFeedbackRequest, + dict, + ], ) def test_update_user_feedback(request_type, transport: str = "grpc"): client = QuestionServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1609,7 +1718,8 @@ def test_update_user_feedback_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = QuestionServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1628,7 +1738,8 @@ async def test_update_user_feedback_async( request_type=question_service.UpdateUserFeedbackRequest, ): client = QuestionServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1667,7 +1778,9 @@ async def test_update_user_feedback_async_from_dict(): def test_update_user_feedback_field_headers(): - client = QuestionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = QuestionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1730,7 +1843,9 @@ async def test_update_user_feedback_field_headers_async(): def test_update_user_feedback_flattened(): - client = QuestionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = QuestionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1758,7 +1873,9 @@ def test_update_user_feedback_flattened(): def test_update_user_feedback_flattened_error(): - client = QuestionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = QuestionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1828,7 +1945,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = QuestionServiceClient( - 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. @@ -1848,7 +1966,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = QuestionServiceClient(client_options=options, transport=transport,) + client = QuestionServiceClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -1864,7 +1985,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = QuestionServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -1909,8 +2031,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = QuestionServiceClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.QuestionServiceGrpcTransport,) + client = QuestionServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.QuestionServiceGrpcTransport, + ) def test_question_service_base_transport_error(): @@ -1959,7 +2086,8 @@ def test_question_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.QuestionServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -2117,7 +2245,8 @@ def test_question_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.QuestionServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2129,7 +2258,8 @@ def test_question_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.QuestionServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2241,7 +2371,9 @@ def test_question_path(): location = "clam" question = "whelk" expected = "projects/{project}/locations/{location}/questions/{question}".format( - project=project, location=location, question=question, + project=project, + location=location, + question=question, ) actual = QuestionServiceClient.question_path(project, location, question) assert expected == actual @@ -2265,7 +2397,9 @@ def test_user_feedback_path(): location = "mussel" question = "winkle" expected = "projects/{project}/locations/{location}/questions/{question}/userFeedback".format( - project=project, location=location, question=question, + project=project, + location=location, + question=question, ) actual = QuestionServiceClient.user_feedback_path(project, location, question) assert expected == actual @@ -2306,7 +2440,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 = QuestionServiceClient.common_folder_path(folder) assert expected == actual @@ -2324,7 +2460,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 = QuestionServiceClient.common_organization_path(organization) assert expected == actual @@ -2342,7 +2480,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 = QuestionServiceClient.common_project_path(project) assert expected == actual @@ -2362,7 +2502,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 = QuestionServiceClient.common_location_path(project, location) assert expected == actual @@ -2387,7 +2528,8 @@ def test_client_with_default_client_info(): transports.QuestionServiceTransport, "_prep_wrapped_messages" ) as prep: client = QuestionServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2396,7 +2538,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = QuestionServiceClient.get_transport_class() transport = 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) @@ -2404,7 +2547,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = QuestionServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close"