From 56c1115fab2ad15d2d3d56f602bdf4dac2cccf5e Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Mon, 28 Mar 2022 23:58:11 +0000 Subject: [PATCH] chore(python): use black==22.3.0 (#202) 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 +- packages/google-cloud-trace/docs/conf.py | 13 +- .../services/trace_service/async_client.py | 28 +- .../trace_v1/services/trace_service/client.py | 69 +++- .../services/trace_service/transports/base.py | 10 +- .../services/trace_service/transports/grpc.py | 3 +- .../google/cloud/trace_v1/types/trace.py | 136 ++++++-- .../services/trace_service/async_client.py | 16 +- .../trace_v2/services/trace_service/client.py | 67 +++- .../services/trace_service/transports/base.py | 14 +- .../services/trace_service/transports/grpc.py | 3 +- .../google/cloud/trace_v2/types/trace.py | 275 ++++++++++++--- .../google/cloud/trace_v2/types/tracing.py | 16 +- packages/google-cloud-trace/noxfile.py | 9 +- .../samples/snippets/noxfile.py | 2 +- .../unit/gapic/trace_v1/test_trace_service.py | 322 ++++++++++++++---- .../unit/gapic/trace_v2/test_trace_service.py | 169 ++++++--- 17 files changed, 902 insertions(+), 252 deletions(-) diff --git a/packages/google-cloud-trace/.github/.OwlBot.lock.yaml b/packages/google-cloud-trace/.github/.OwlBot.lock.yaml index 44c78f7cc12d..87dd00611576 100644 --- a/packages/google-cloud-trace/.github/.OwlBot.lock.yaml +++ b/packages/google-cloud-trace/.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/packages/google-cloud-trace/docs/conf.py b/packages/google-cloud-trace/docs/conf.py index ee11ca992722..457ae096680b 100644 --- a/packages/google-cloud-trace/docs/conf.py +++ b/packages/google-cloud-trace/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-cloud-trace", "google-cloud-trace Documentation", [author], 1,) + ( + root_doc, + "google-cloud-trace", + "google-cloud-trace 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/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/async_client.py b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/async_client.py index 0fc21251780e..a88b6601b28e 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/async_client.py +++ b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/async_client.py @@ -297,12 +297,20 @@ def sample_list_traces(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListTracesAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -409,7 +417,12 @@ def sample_get_trace(): ) # 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 @@ -510,7 +523,10 @@ def sample_patch_traces(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def __aenter__(self): @@ -522,7 +538,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-trace",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-trace", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/client.py b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/client.py index 46a9370ea416..ea15f7e0d7ff 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/client.py +++ b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/client.py @@ -53,7 +53,10 @@ class TraceServiceClientMeta(type): _transport_registry["grpc"] = TraceServiceGrpcTransport _transport_registry["grpc_asyncio"] = TraceServiceGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[TraceServiceTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[TraceServiceTransport]: """Returns an appropriate transport class. Args: @@ -164,7 +167,9 @@ def transport(self) -> TraceServiceTransport: 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, @@ -177,9 +182,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]: @@ -188,9 +197,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]: @@ -199,9 +212,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]: @@ -210,10 +227,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 @@ -472,12 +493,20 @@ def sample_list_traces(): rpc = self._transport._wrapped_methods[self._transport.list_traces] # 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.ListTracesPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -574,7 +603,12 @@ def sample_get_trace(): rpc = self._transport._wrapped_methods[self._transport.get_trace] # 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 @@ -665,7 +699,10 @@ def sample_patch_traces(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def __enter__(self): @@ -684,7 +721,9 @@ def __exit__(self, type, value, traceback): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-trace",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-trace", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/base.py b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/base.py index c7a9799f4d71..0c1cfdafa3d8 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/base.py +++ b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/base.py @@ -30,7 +30,9 @@ try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-trace",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-trace", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -173,9 +175,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/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/grpc.py b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/grpc.py index e8afeb42f33a..92073d68cf05 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/grpc.py +++ b/packages/google-cloud-trace/google/cloud/trace_v1/services/trace_service/transports/grpc.py @@ -230,8 +230,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/packages/google-cloud-trace/google/cloud/trace_v1/types/trace.py b/packages/google-cloud-trace/google/cloud/trace_v1/types/trace.py index cff0a93d2069..c5719ddca81d 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v1/types/trace.py +++ b/packages/google-cloud-trace/google/cloud/trace_v1/types/trace.py @@ -49,9 +49,19 @@ class Trace(proto.Message): Collection of spans in the trace. """ - project_id = proto.Field(proto.STRING, number=1,) - trace_id = proto.Field(proto.STRING, number=2,) - spans = proto.RepeatedField(proto.MESSAGE, number=3, message="TraceSpan",) + project_id = proto.Field( + proto.STRING, + number=1, + ) + trace_id = proto.Field( + proto.STRING, + number=2, + ) + spans = proto.RepeatedField( + proto.MESSAGE, + number=3, + message="TraceSpan", + ) class Traces(proto.Message): @@ -62,7 +72,11 @@ class Traces(proto.Message): List of traces. """ - traces = proto.RepeatedField(proto.MESSAGE, number=1, message="Trace",) + traces = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Trace", + ) class TraceSpan(proto.Message): @@ -148,13 +162,38 @@ class SpanKind(proto.Enum): RPC_SERVER = 1 RPC_CLIENT = 2 - span_id = proto.Field(proto.FIXED64, number=1,) - kind = proto.Field(proto.ENUM, number=2, enum=SpanKind,) - name = proto.Field(proto.STRING, number=3,) - start_time = proto.Field(proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp,) - end_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) - parent_span_id = proto.Field(proto.FIXED64, number=6,) - labels = proto.MapField(proto.STRING, proto.STRING, number=7,) + span_id = proto.Field( + proto.FIXED64, + number=1, + ) + kind = proto.Field( + proto.ENUM, + number=2, + enum=SpanKind, + ) + name = proto.Field( + proto.STRING, + number=3, + ) + start_time = proto.Field( + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp_pb2.Timestamp, + ) + parent_span_id = proto.Field( + proto.FIXED64, + number=6, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=7, + ) class ListTracesRequest(proto.Message): @@ -243,14 +282,41 @@ class ViewType(proto.Enum): ROOTSPAN = 2 COMPLETE = 3 - project_id = proto.Field(proto.STRING, number=1,) - view = proto.Field(proto.ENUM, number=2, enum=ViewType,) - page_size = proto.Field(proto.INT32, number=3,) - page_token = proto.Field(proto.STRING, number=4,) - start_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) - end_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) - filter = proto.Field(proto.STRING, number=7,) - order_by = proto.Field(proto.STRING, number=8,) + project_id = proto.Field( + proto.STRING, + number=1, + ) + view = proto.Field( + proto.ENUM, + number=2, + enum=ViewType, + ) + page_size = proto.Field( + proto.INT32, + number=3, + ) + page_token = proto.Field( + proto.STRING, + number=4, + ) + start_time = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + filter = proto.Field( + proto.STRING, + number=7, + ) + order_by = proto.Field( + proto.STRING, + number=8, + ) class ListTracesResponse(proto.Message): @@ -271,8 +337,15 @@ class ListTracesResponse(proto.Message): def raw_page(self): return self - traces = proto.RepeatedField(proto.MESSAGE, number=1, message="Trace",) - next_page_token = proto.Field(proto.STRING, number=2,) + traces = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Trace", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class GetTraceRequest(proto.Message): @@ -286,8 +359,14 @@ class GetTraceRequest(proto.Message): Required. ID of the trace to return. """ - project_id = proto.Field(proto.STRING, number=1,) - trace_id = proto.Field(proto.STRING, number=2,) + project_id = proto.Field( + proto.STRING, + number=1, + ) + trace_id = proto.Field( + proto.STRING, + number=2, + ) class PatchTracesRequest(proto.Message): @@ -301,8 +380,15 @@ class PatchTracesRequest(proto.Message): Required. The body of the message. """ - project_id = proto.Field(proto.STRING, number=1,) - traces = proto.Field(proto.MESSAGE, number=2, message="Traces",) + project_id = proto.Field( + proto.STRING, + number=1, + ) + traces = proto.Field( + proto.MESSAGE, + number=2, + message="Traces", + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/async_client.py b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/async_client.py index 6fc2aa9393d6..933ed797f586 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/async_client.py +++ b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/async_client.py @@ -302,7 +302,10 @@ def sample_batch_write_spans(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def create_span( @@ -393,7 +396,12 @@ def sample_create_span(): ) # 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 @@ -407,7 +415,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-trace",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-trace", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/client.py b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/client.py index 1f057c7fa0c7..edc50f556404 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/client.py +++ b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/client.py @@ -56,7 +56,10 @@ class TraceServiceClientMeta(type): _transport_registry["grpc"] = TraceServiceGrpcTransport _transport_registry["grpc_asyncio"] = TraceServiceGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[TraceServiceTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[TraceServiceTransport]: """Returns an appropriate transport class. Args: @@ -167,10 +170,16 @@ def transport(self) -> TraceServiceTransport: return self._transport @staticmethod - def span_path(project: str, trace: str, span: str,) -> str: + def span_path( + project: str, + trace: str, + span: str, + ) -> str: """Returns a fully-qualified span string.""" return "projects/{project}/traces/{trace}/spans/{span}".format( - project=project, trace=trace, span=span, + project=project, + trace=trace, + span=span, ) @staticmethod @@ -183,7 +192,9 @@ def parse_span_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, @@ -196,9 +207,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]: @@ -207,9 +222,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]: @@ -218,9 +237,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]: @@ -229,10 +252,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 @@ -501,7 +528,10 @@ def sample_batch_write_spans(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def create_span( @@ -583,7 +613,12 @@ def sample_create_span(): ) # 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 @@ -604,7 +639,9 @@ def __exit__(self, type, value, traceback): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-trace",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-trace", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/base.py b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/base.py index d3a9b410672b..7242a2707835 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/base.py +++ b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/base.py @@ -31,7 +31,9 @@ try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-trace",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-trace", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -124,7 +126,9 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.batch_write_spans: gapic_v1.method.wrap_method( - self.batch_write_spans, default_timeout=120.0, client_info=client_info, + self.batch_write_spans, + default_timeout=120.0, + client_info=client_info, ), self.create_span: gapic_v1.method.wrap_method( self.create_span, @@ -146,9 +150,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/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/grpc.py b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/grpc.py index 914be71ad2dd..0bed04e2ca13 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/grpc.py +++ b/packages/google-cloud-trace/google/cloud/trace_v2/services/trace_service/transports/grpc.py @@ -231,8 +231,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/packages/google-cloud-trace/google/cloud/trace_v2/types/trace.py b/packages/google-cloud-trace/google/cloud/trace_v2/types/trace.py index 0bc816b835c2..ea8ae7b49c02 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v2/types/trace.py +++ b/packages/google-cloud-trace/google/cloud/trace_v2/types/trace.py @@ -22,7 +22,13 @@ __protobuf__ = proto.module( package="google.devtools.cloudtrace.v2", - manifest={"Span", "AttributeValue", "StackTrace", "Module", "TruncatableString",}, + manifest={ + "Span", + "AttributeValue", + "StackTrace", + "Module", + "TruncatableString", + }, ) @@ -147,9 +153,15 @@ class Attributes(proto.Message): """ attribute_map = proto.MapField( - proto.STRING, proto.MESSAGE, number=1, message="AttributeValue", + proto.STRING, + proto.MESSAGE, + number=1, + message="AttributeValue", + ) + dropped_attributes_count = proto.Field( + proto.INT32, + number=2, ) - dropped_attributes_count = proto.Field(proto.INT32, number=2,) class TimeEvent(proto.Message): r"""A time-stamped annotation or message event in the Span. @@ -190,10 +202,14 @@ class Annotation(proto.Message): """ description = proto.Field( - proto.MESSAGE, number=1, message="TruncatableString", + proto.MESSAGE, + number=1, + message="TruncatableString", ) attributes = proto.Field( - proto.MESSAGE, number=2, message="Span.Attributes", + proto.MESSAGE, + number=2, + message="Span.Attributes", ) class MessageEvent(proto.Message): @@ -224,15 +240,33 @@ class Type(proto.Enum): RECEIVED = 2 type = proto.Field( - proto.ENUM, number=1, enum="Span.TimeEvent.MessageEvent.Type", + proto.ENUM, + number=1, + enum="Span.TimeEvent.MessageEvent.Type", + ) + id = proto.Field( + proto.INT64, + number=2, + ) + uncompressed_size_bytes = proto.Field( + proto.INT64, + number=3, + ) + compressed_size_bytes = proto.Field( + proto.INT64, + number=4, ) - id = proto.Field(proto.INT64, number=2,) - uncompressed_size_bytes = proto.Field(proto.INT64, number=3,) - compressed_size_bytes = proto.Field(proto.INT64, number=4,) - time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) + time = proto.Field( + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) annotation = proto.Field( - proto.MESSAGE, number=2, oneof="value", message="Span.TimeEvent.Annotation", + proto.MESSAGE, + number=2, + oneof="value", + message="Span.TimeEvent.Annotation", ) message_event = proto.Field( proto.MESSAGE, @@ -260,10 +294,18 @@ class TimeEvents(proto.Message): """ time_event = proto.RepeatedField( - proto.MESSAGE, number=1, message="Span.TimeEvent", + proto.MESSAGE, + number=1, + message="Span.TimeEvent", + ) + dropped_annotations_count = proto.Field( + proto.INT32, + number=2, + ) + dropped_message_events_count = proto.Field( + proto.INT32, + number=3, ) - dropped_annotations_count = proto.Field(proto.INT32, number=2,) - dropped_message_events_count = proto.Field(proto.INT32, number=3,) class Link(proto.Message): r"""A pointer from the current span to another span in the same @@ -293,10 +335,24 @@ class Type(proto.Enum): CHILD_LINKED_SPAN = 1 PARENT_LINKED_SPAN = 2 - trace_id = proto.Field(proto.STRING, number=1,) - span_id = proto.Field(proto.STRING, number=2,) - type = proto.Field(proto.ENUM, number=3, enum="Span.Link.Type",) - attributes = proto.Field(proto.MESSAGE, number=4, message="Span.Attributes",) + trace_id = proto.Field( + proto.STRING, + number=1, + ) + span_id = proto.Field( + proto.STRING, + number=2, + ) + type = proto.Field( + proto.ENUM, + number=3, + enum="Span.Link.Type", + ) + attributes = proto.Field( + proto.MESSAGE, + number=4, + message="Span.Attributes", + ) class Links(proto.Message): r"""A collection of links, which are references from this span to @@ -311,27 +367,83 @@ class Links(proto.Message): links were dropped. """ - link = proto.RepeatedField(proto.MESSAGE, number=1, message="Span.Link",) - dropped_links_count = proto.Field(proto.INT32, number=2,) - - name = proto.Field(proto.STRING, number=1,) - span_id = proto.Field(proto.STRING, number=2,) - parent_span_id = proto.Field(proto.STRING, number=3,) - display_name = proto.Field(proto.MESSAGE, number=4, message="TruncatableString",) - start_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) - end_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) - attributes = proto.Field(proto.MESSAGE, number=7, message=Attributes,) - stack_trace = proto.Field(proto.MESSAGE, number=8, message="StackTrace",) - time_events = proto.Field(proto.MESSAGE, number=9, message=TimeEvents,) - links = proto.Field(proto.MESSAGE, number=10, message=Links,) - status = proto.Field(proto.MESSAGE, number=11, message=status_pb2.Status,) + link = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Span.Link", + ) + dropped_links_count = proto.Field( + proto.INT32, + number=2, + ) + + name = proto.Field( + proto.STRING, + number=1, + ) + span_id = proto.Field( + proto.STRING, + number=2, + ) + parent_span_id = proto.Field( + proto.STRING, + number=3, + ) + display_name = proto.Field( + proto.MESSAGE, + number=4, + message="TruncatableString", + ) + start_time = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + attributes = proto.Field( + proto.MESSAGE, + number=7, + message=Attributes, + ) + stack_trace = proto.Field( + proto.MESSAGE, + number=8, + message="StackTrace", + ) + time_events = proto.Field( + proto.MESSAGE, + number=9, + message=TimeEvents, + ) + links = proto.Field( + proto.MESSAGE, + number=10, + message=Links, + ) + status = proto.Field( + proto.MESSAGE, + number=11, + message=status_pb2.Status, + ) same_process_as_parent_span = proto.Field( - proto.MESSAGE, number=12, message=wrappers_pb2.BoolValue, + proto.MESSAGE, + number=12, + message=wrappers_pb2.BoolValue, ) child_span_count = proto.Field( - proto.MESSAGE, number=13, message=wrappers_pb2.Int32Value, + proto.MESSAGE, + number=13, + message=wrappers_pb2.Int32Value, + ) + span_kind = proto.Field( + proto.ENUM, + number=14, + enum=SpanKind, ) - span_kind = proto.Field(proto.ENUM, number=14, enum=SpanKind,) class AttributeValue(proto.Message): @@ -360,10 +472,21 @@ class AttributeValue(proto.Message): """ string_value = proto.Field( - proto.MESSAGE, number=1, oneof="value", message="TruncatableString", + proto.MESSAGE, + number=1, + oneof="value", + message="TruncatableString", + ) + int_value = proto.Field( + proto.INT64, + number=2, + oneof="value", + ) + bool_value = proto.Field( + proto.BOOL, + number=3, + oneof="value", ) - int_value = proto.Field(proto.INT64, number=2, oneof="value",) - bool_value = proto.Field(proto.BOOL, number=3, oneof="value",) class StackTrace(proto.Message): @@ -416,17 +539,37 @@ class StackFrame(proto.Message): """ function_name = proto.Field( - proto.MESSAGE, number=1, message="TruncatableString", + proto.MESSAGE, + number=1, + message="TruncatableString", ) original_function_name = proto.Field( - proto.MESSAGE, number=2, message="TruncatableString", + proto.MESSAGE, + number=2, + message="TruncatableString", + ) + file_name = proto.Field( + proto.MESSAGE, + number=3, + message="TruncatableString", + ) + line_number = proto.Field( + proto.INT64, + number=4, + ) + column_number = proto.Field( + proto.INT64, + number=5, + ) + load_module = proto.Field( + proto.MESSAGE, + number=6, + message="Module", ) - file_name = proto.Field(proto.MESSAGE, number=3, message="TruncatableString",) - line_number = proto.Field(proto.INT64, number=4,) - column_number = proto.Field(proto.INT64, number=5,) - load_module = proto.Field(proto.MESSAGE, number=6, message="Module",) source_version = proto.Field( - proto.MESSAGE, number=7, message="TruncatableString", + proto.MESSAGE, + number=7, + message="TruncatableString", ) class StackFrames(proto.Message): @@ -443,12 +586,24 @@ class StackFrames(proto.Message): """ frame = proto.RepeatedField( - proto.MESSAGE, number=1, message="StackTrace.StackFrame", + proto.MESSAGE, + number=1, + message="StackTrace.StackFrame", + ) + dropped_frames_count = proto.Field( + proto.INT32, + number=2, ) - dropped_frames_count = proto.Field(proto.INT32, number=2,) - stack_frames = proto.Field(proto.MESSAGE, number=1, message=StackFrames,) - stack_trace_hash_id = proto.Field(proto.INT64, number=2,) + stack_frames = proto.Field( + proto.MESSAGE, + number=1, + message=StackFrames, + ) + stack_trace_hash_id = proto.Field( + proto.INT64, + number=2, + ) class Module(proto.Message): @@ -464,8 +619,16 @@ class Module(proto.Message): hash of its contents (up to 128 bytes). """ - module = proto.Field(proto.MESSAGE, number=1, message="TruncatableString",) - build_id = proto.Field(proto.MESSAGE, number=2, message="TruncatableString",) + module = proto.Field( + proto.MESSAGE, + number=1, + message="TruncatableString", + ) + build_id = proto.Field( + proto.MESSAGE, + number=2, + message="TruncatableString", + ) class TruncatableString(proto.Message): @@ -489,8 +652,14 @@ class TruncatableString(proto.Message): not shortened. """ - value = proto.Field(proto.STRING, number=1,) - truncated_byte_count = proto.Field(proto.INT32, number=2,) + value = proto.Field( + proto.STRING, + number=1, + ) + truncated_byte_count = proto.Field( + proto.INT32, + number=2, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-trace/google/cloud/trace_v2/types/tracing.py b/packages/google-cloud-trace/google/cloud/trace_v2/types/tracing.py index 8cbfa56d785a..f2ce5e508b80 100644 --- a/packages/google-cloud-trace/google/cloud/trace_v2/types/tracing.py +++ b/packages/google-cloud-trace/google/cloud/trace_v2/types/tracing.py @@ -19,7 +19,10 @@ __protobuf__ = proto.module( - package="google.devtools.cloudtrace.v2", manifest={"BatchWriteSpansRequest",}, + package="google.devtools.cloudtrace.v2", + manifest={ + "BatchWriteSpansRequest", + }, ) @@ -36,8 +39,15 @@ class BatchWriteSpansRequest(proto.Message): are undefined. """ - name = proto.Field(proto.STRING, number=1,) - spans = proto.RepeatedField(proto.MESSAGE, number=2, message=trace.Span,) + name = proto.Field( + proto.STRING, + number=1, + ) + spans = proto.RepeatedField( + proto.MESSAGE, + number=2, + message=trace.Span, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-trace/noxfile.py b/packages/google-cloud-trace/noxfile.py index 2a2001c49998..3addb4ed9431 100644 --- a/packages/google-cloud-trace/noxfile.py +++ b/packages/google-cloud-trace/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/packages/google-cloud-trace/samples/snippets/noxfile.py b/packages/google-cloud-trace/samples/snippets/noxfile.py index 4c808af73ea2..949e0fde9ae1 100644 --- a/packages/google-cloud-trace/samples/snippets/noxfile.py +++ b/packages/google-cloud-trace/samples/snippets/noxfile.py @@ -29,7 +29,7 @@ # WARNING - WARNING - WARNING - WARNING - WARNING # WARNING - WARNING - WARNING - WARNING - WARNING -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" # Copy `noxfile_config.py` to your directory and modify it instead. diff --git a/packages/google-cloud-trace/tests/unit/gapic/trace_v1/test_trace_service.py b/packages/google-cloud-trace/tests/unit/gapic/trace_v1/test_trace_service.py index 6e5c0cea5d35..2c38d3cfc6cf 100644 --- a/packages/google-cloud-trace/tests/unit/gapic/trace_v1/test_trace_service.py +++ b/packages/google-cloud-trace/tests/unit/gapic/trace_v1/test_trace_service.py @@ -82,7 +82,13 @@ def test__get_default_mtls_endpoint(): assert TraceServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [TraceServiceClient, TraceServiceAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + TraceServiceClient, + TraceServiceAsyncClient, + ], +) def test_trace_service_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -122,7 +128,13 @@ def test_trace_service_client_service_account_always_use_jwt( use_jwt.assert_not_called() -@pytest.mark.parametrize("client_class", [TraceServiceClient, TraceServiceAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + TraceServiceClient, + TraceServiceAsyncClient, + ], +) def test_trace_service_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -477,7 +489,9 @@ def test_trace_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) @@ -619,10 +633,17 @@ def test_trace_service_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [trace.ListTracesRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + trace.ListTracesRequest, + dict, + ], +) def test_list_traces(request_type, transport: str = "grpc"): client = TraceServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -651,7 +672,8 @@ def test_list_traces_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 = TraceServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -667,7 +689,8 @@ async def test_list_traces_async( transport: str = "grpc_asyncio", request_type=trace.ListTracesRequest ): client = TraceServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -678,7 +701,9 @@ async def test_list_traces_async( with mock.patch.object(type(client.transport.list_traces), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - trace.ListTracesResponse(next_page_token="next_page_token_value",) + trace.ListTracesResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_traces(request) @@ -698,7 +723,9 @@ async def test_list_traces_async_from_dict(): def test_list_traces_flattened(): - client = TraceServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = TraceServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_traces), "__call__") as call: @@ -706,7 +733,9 @@ def test_list_traces_flattened(): call.return_value = trace.ListTracesResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_traces(project_id="project_id_value",) + client.list_traces( + project_id="project_id_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -718,19 +747,24 @@ def test_list_traces_flattened(): def test_list_traces_flattened_error(): - client = TraceServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = TraceServiceClient( + 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.list_traces( - trace.ListTracesRequest(), project_id="project_id_value", + trace.ListTracesRequest(), + project_id="project_id_value", ) @pytest.mark.asyncio async def test_list_traces_flattened_async(): - client = TraceServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = TraceServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_traces), "__call__") as call: @@ -742,7 +776,9 @@ async def test_list_traces_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_traces(project_id="project_id_value",) + response = await client.list_traces( + project_id="project_id_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -755,19 +791,23 @@ async def test_list_traces_flattened_async(): @pytest.mark.asyncio async def test_list_traces_flattened_error_async(): - client = TraceServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = TraceServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_traces( - trace.ListTracesRequest(), project_id="project_id_value", + trace.ListTracesRequest(), + project_id="project_id_value", ) def test_list_traces_pager(transport_name: str = "grpc"): client = TraceServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -775,12 +815,29 @@ def test_list_traces_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( trace.ListTracesResponse( - traces=[trace.Trace(), trace.Trace(), trace.Trace(),], + traces=[ + trace.Trace(), + trace.Trace(), + trace.Trace(), + ], next_page_token="abc", ), - trace.ListTracesResponse(traces=[], next_page_token="def",), - trace.ListTracesResponse(traces=[trace.Trace(),], next_page_token="ghi",), - trace.ListTracesResponse(traces=[trace.Trace(), trace.Trace(),],), + trace.ListTracesResponse( + traces=[], + next_page_token="def", + ), + trace.ListTracesResponse( + traces=[ + trace.Trace(), + ], + next_page_token="ghi", + ), + trace.ListTracesResponse( + traces=[ + trace.Trace(), + trace.Trace(), + ], + ), RuntimeError, ) @@ -796,7 +853,8 @@ def test_list_traces_pager(transport_name: str = "grpc"): def test_list_traces_pages(transport_name: str = "grpc"): client = TraceServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -804,12 +862,29 @@ def test_list_traces_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( trace.ListTracesResponse( - traces=[trace.Trace(), trace.Trace(), trace.Trace(),], + traces=[ + trace.Trace(), + trace.Trace(), + trace.Trace(), + ], next_page_token="abc", ), - trace.ListTracesResponse(traces=[], next_page_token="def",), - trace.ListTracesResponse(traces=[trace.Trace(),], next_page_token="ghi",), - trace.ListTracesResponse(traces=[trace.Trace(), trace.Trace(),],), + trace.ListTracesResponse( + traces=[], + next_page_token="def", + ), + trace.ListTracesResponse( + traces=[ + trace.Trace(), + ], + next_page_token="ghi", + ), + trace.ListTracesResponse( + traces=[ + trace.Trace(), + trace.Trace(), + ], + ), RuntimeError, ) pages = list(client.list_traces(request={}).pages) @@ -819,7 +894,9 @@ def test_list_traces_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_traces_async_pager(): - client = TraceServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = TraceServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -828,15 +905,34 @@ async def test_list_traces_async_pager(): # Set the response to a series of pages. call.side_effect = ( trace.ListTracesResponse( - traces=[trace.Trace(), trace.Trace(), trace.Trace(),], + traces=[ + trace.Trace(), + trace.Trace(), + trace.Trace(), + ], next_page_token="abc", ), - trace.ListTracesResponse(traces=[], next_page_token="def",), - trace.ListTracesResponse(traces=[trace.Trace(),], next_page_token="ghi",), - trace.ListTracesResponse(traces=[trace.Trace(), trace.Trace(),],), + trace.ListTracesResponse( + traces=[], + next_page_token="def", + ), + trace.ListTracesResponse( + traces=[ + trace.Trace(), + ], + next_page_token="ghi", + ), + trace.ListTracesResponse( + traces=[ + trace.Trace(), + trace.Trace(), + ], + ), RuntimeError, ) - async_pager = await client.list_traces(request={},) + async_pager = await client.list_traces( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -848,7 +944,9 @@ async def test_list_traces_async_pager(): @pytest.mark.asyncio async def test_list_traces_async_pages(): - client = TraceServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = TraceServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -857,12 +955,29 @@ async def test_list_traces_async_pages(): # Set the response to a series of pages. call.side_effect = ( trace.ListTracesResponse( - traces=[trace.Trace(), trace.Trace(), trace.Trace(),], + traces=[ + trace.Trace(), + trace.Trace(), + trace.Trace(), + ], next_page_token="abc", ), - trace.ListTracesResponse(traces=[], next_page_token="def",), - trace.ListTracesResponse(traces=[trace.Trace(),], next_page_token="ghi",), - trace.ListTracesResponse(traces=[trace.Trace(), trace.Trace(),],), + trace.ListTracesResponse( + traces=[], + next_page_token="def", + ), + trace.ListTracesResponse( + traces=[ + trace.Trace(), + ], + next_page_token="ghi", + ), + trace.ListTracesResponse( + traces=[ + trace.Trace(), + trace.Trace(), + ], + ), RuntimeError, ) pages = [] @@ -872,10 +987,17 @@ async def test_list_traces_async_pages(): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [trace.GetTraceRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + trace.GetTraceRequest, + dict, + ], +) def test_get_trace(request_type, transport: str = "grpc"): client = TraceServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -886,7 +1008,8 @@ def test_get_trace(request_type, transport: str = "grpc"): with mock.patch.object(type(client.transport.get_trace), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = trace.Trace( - project_id="project_id_value", trace_id="trace_id_value", + project_id="project_id_value", + trace_id="trace_id_value", ) response = client.get_trace(request) @@ -905,7 +1028,8 @@ def test_get_trace_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 = TraceServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -921,7 +1045,8 @@ async def test_get_trace_async( transport: str = "grpc_asyncio", request_type=trace.GetTraceRequest ): client = TraceServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -932,7 +1057,10 @@ async def test_get_trace_async( with mock.patch.object(type(client.transport.get_trace), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - trace.Trace(project_id="project_id_value", trace_id="trace_id_value",) + trace.Trace( + project_id="project_id_value", + trace_id="trace_id_value", + ) ) response = await client.get_trace(request) @@ -953,7 +1081,9 @@ async def test_get_trace_async_from_dict(): def test_get_trace_flattened(): - client = TraceServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = TraceServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_trace), "__call__") as call: @@ -962,7 +1092,8 @@ def test_get_trace_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_trace( - project_id="project_id_value", trace_id="trace_id_value", + project_id="project_id_value", + trace_id="trace_id_value", ) # Establish that the underlying call was made with the expected @@ -978,7 +1109,9 @@ def test_get_trace_flattened(): def test_get_trace_flattened_error(): - client = TraceServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = TraceServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -992,7 +1125,9 @@ def test_get_trace_flattened_error(): @pytest.mark.asyncio async def test_get_trace_flattened_async(): - client = TraceServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = TraceServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_trace), "__call__") as call: @@ -1003,7 +1138,8 @@ async def test_get_trace_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.get_trace( - project_id="project_id_value", trace_id="trace_id_value", + project_id="project_id_value", + trace_id="trace_id_value", ) # Establish that the underlying call was made with the expected @@ -1020,7 +1156,9 @@ async def test_get_trace_flattened_async(): @pytest.mark.asyncio async def test_get_trace_flattened_error_async(): - client = TraceServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = TraceServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1032,10 +1170,17 @@ async def test_get_trace_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [trace.PatchTracesRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + trace.PatchTracesRequest, + dict, + ], +) def test_patch_traces(request_type, transport: str = "grpc"): client = TraceServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1061,7 +1206,8 @@ def test_patch_traces_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 = TraceServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1077,7 +1223,8 @@ async def test_patch_traces_async( transport: str = "grpc_asyncio", request_type=trace.PatchTracesRequest ): client = TraceServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1105,7 +1252,9 @@ async def test_patch_traces_async_from_dict(): def test_patch_traces_flattened(): - client = TraceServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = TraceServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.patch_traces), "__call__") as call: @@ -1131,7 +1280,9 @@ def test_patch_traces_flattened(): def test_patch_traces_flattened_error(): - client = TraceServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = TraceServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1145,7 +1296,9 @@ def test_patch_traces_flattened_error(): @pytest.mark.asyncio async def test_patch_traces_flattened_async(): - client = TraceServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = TraceServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.patch_traces), "__call__") as call: @@ -1174,7 +1327,9 @@ async def test_patch_traces_flattened_async(): @pytest.mark.asyncio async def test_patch_traces_flattened_error_async(): - client = TraceServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = TraceServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1193,7 +1348,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = TraceServiceClient( - 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. @@ -1213,7 +1369,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = TraceServiceClient(client_options=options, transport=transport,) + client = TraceServiceClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -1229,7 +1388,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = TraceServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -1274,8 +1434,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = TraceServiceClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.TraceServiceGrpcTransport,) + client = TraceServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.TraceServiceGrpcTransport, + ) def test_trace_service_base_transport_error(): @@ -1322,7 +1487,8 @@ def test_trace_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.TraceServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -1493,7 +1659,8 @@ def test_trace_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.TraceServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1505,7 +1672,8 @@ def test_trace_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.TraceServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1626,7 +1794,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 = TraceServiceClient.common_folder_path(folder) assert expected == actual @@ -1644,7 +1814,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 = TraceServiceClient.common_organization_path(organization) assert expected == actual @@ -1662,7 +1834,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 = TraceServiceClient.common_project_path(project) assert expected == actual @@ -1682,7 +1856,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 = TraceServiceClient.common_location_path(project, location) assert expected == actual @@ -1707,7 +1882,8 @@ def test_client_with_default_client_info(): transports.TraceServiceTransport, "_prep_wrapped_messages" ) as prep: client = TraceServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1716,7 +1892,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = TraceServiceClient.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) @@ -1724,7 +1901,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = TraceServiceAsyncClient( - 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/packages/google-cloud-trace/tests/unit/gapic/trace_v2/test_trace_service.py b/packages/google-cloud-trace/tests/unit/gapic/trace_v2/test_trace_service.py index 50f125b8f42c..bcf22047db81 100644 --- a/packages/google-cloud-trace/tests/unit/gapic/trace_v2/test_trace_service.py +++ b/packages/google-cloud-trace/tests/unit/gapic/trace_v2/test_trace_service.py @@ -85,7 +85,13 @@ def test__get_default_mtls_endpoint(): assert TraceServiceClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [TraceServiceClient, TraceServiceAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + TraceServiceClient, + TraceServiceAsyncClient, + ], +) def test_trace_service_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -125,7 +131,13 @@ def test_trace_service_client_service_account_always_use_jwt( use_jwt.assert_not_called() -@pytest.mark.parametrize("client_class", [TraceServiceClient, TraceServiceAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + TraceServiceClient, + TraceServiceAsyncClient, + ], +) def test_trace_service_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -480,7 +492,9 @@ def test_trace_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) @@ -621,10 +635,17 @@ def test_trace_service_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [tracing.BatchWriteSpansRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + tracing.BatchWriteSpansRequest, + dict, + ], +) def test_batch_write_spans(request_type, transport: str = "grpc"): client = TraceServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -652,7 +673,8 @@ def test_batch_write_spans_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 = TraceServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -670,7 +692,8 @@ async def test_batch_write_spans_async( transport: str = "grpc_asyncio", request_type=tracing.BatchWriteSpansRequest ): client = TraceServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -700,7 +723,9 @@ async def test_batch_write_spans_async_from_dict(): def test_batch_write_spans_field_headers(): - client = TraceServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = TraceServiceClient( + 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. @@ -722,12 +747,17 @@ def test_batch_write_spans_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 async def test_batch_write_spans_field_headers_async(): - client = TraceServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = TraceServiceAsyncClient( + 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. @@ -749,11 +779,16 @@ async def test_batch_write_spans_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_batch_write_spans_flattened(): - client = TraceServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = TraceServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -764,7 +799,8 @@ def test_batch_write_spans_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.batch_write_spans( - name="name_value", spans=[trace.Span(name="name_value")], + name="name_value", + spans=[trace.Span(name="name_value")], ) # Establish that the underlying call was made with the expected @@ -780,7 +816,9 @@ def test_batch_write_spans_flattened(): def test_batch_write_spans_flattened_error(): - client = TraceServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = TraceServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -794,7 +832,9 @@ def test_batch_write_spans_flattened_error(): @pytest.mark.asyncio async def test_batch_write_spans_flattened_async(): - client = TraceServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = TraceServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -807,7 +847,8 @@ async def test_batch_write_spans_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.batch_write_spans( - name="name_value", spans=[trace.Span(name="name_value")], + name="name_value", + spans=[trace.Span(name="name_value")], ) # Establish that the underlying call was made with the expected @@ -824,7 +865,9 @@ async def test_batch_write_spans_flattened_async(): @pytest.mark.asyncio async def test_batch_write_spans_flattened_error_async(): - client = TraceServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = TraceServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -836,10 +879,17 @@ async def test_batch_write_spans_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [trace.Span, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + trace.Span, + dict, + ], +) def test_create_span(request_type, transport: str = "grpc"): client = TraceServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -874,7 +924,8 @@ def test_create_span_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 = TraceServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -890,7 +941,8 @@ async def test_create_span_async( transport: str = "grpc_asyncio", request_type=trace.Span ): client = TraceServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -929,7 +981,9 @@ async def test_create_span_async_from_dict(): def test_create_span_field_headers(): - client = TraceServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = TraceServiceClient( + 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. @@ -949,12 +1003,17 @@ def test_create_span_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 async def test_create_span_field_headers_async(): - client = TraceServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = TraceServiceAsyncClient( + 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. @@ -974,7 +1033,10 @@ async def test_create_span_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_credentials_transport_error(): @@ -984,7 +1046,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = TraceServiceClient( - 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. @@ -1004,7 +1067,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = TraceServiceClient(client_options=options, transport=transport,) + client = TraceServiceClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -1020,7 +1086,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = TraceServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -1065,8 +1132,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = TraceServiceClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.TraceServiceGrpcTransport,) + client = TraceServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.TraceServiceGrpcTransport, + ) def test_trace_service_base_transport_error(): @@ -1112,7 +1184,8 @@ def test_trace_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.TraceServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -1279,7 +1352,8 @@ def test_trace_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.TraceServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1291,7 +1365,8 @@ def test_trace_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.TraceServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1395,7 +1470,9 @@ def test_span_path(): trace = "clam" span = "whelk" expected = "projects/{project}/traces/{trace}/spans/{span}".format( - project=project, trace=trace, span=span, + project=project, + trace=trace, + span=span, ) actual = TraceServiceClient.span_path(project, trace, span) assert expected == actual @@ -1436,7 +1513,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "winkle" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = TraceServiceClient.common_folder_path(folder) assert expected == actual @@ -1454,7 +1533,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "scallop" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = TraceServiceClient.common_organization_path(organization) assert expected == actual @@ -1472,7 +1553,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "squid" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = TraceServiceClient.common_project_path(project) assert expected == actual @@ -1492,7 +1575,8 @@ def test_common_location_path(): project = "whelk" location = "octopus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = TraceServiceClient.common_location_path(project, location) assert expected == actual @@ -1517,7 +1601,8 @@ def test_client_with_default_client_info(): transports.TraceServiceTransport, "_prep_wrapped_messages" ) as prep: client = TraceServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1526,7 +1611,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = TraceServiceClient.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) @@ -1534,7 +1620,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = TraceServiceAsyncClient( - 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"