From a2667b80c35f44fbd81a20456d58a7a7ce91f64b Mon Sep 17 00:00:00 2001 From: Pau Freixes Date: Tue, 7 Jan 2020 01:32:47 +0100 Subject: [PATCH] make YAPF happy --- .../grpcio/grpc/experimental/aio/__init__.py | 18 ++++---- .../grpcio/grpc/experimental/aio/_channel.py | 10 +++-- .../grpc/experimental/aio/_interceptor.py | 27 ++++++------ .../tests_aio/unit/interceptor_test.py | 41 +++++++++++-------- 4 files changed, 52 insertions(+), 44 deletions(-) diff --git a/src/python/grpcio/grpc/experimental/aio/__init__.py b/src/python/grpcio/grpc/experimental/aio/__init__.py index 2ece2ed3775..9a0b6a6fa64 100644 --- a/src/python/grpcio/grpc/experimental/aio/__init__.py +++ b/src/python/grpcio/grpc/experimental/aio/__init__.py @@ -52,16 +52,16 @@ def insecure_channel( Returns: A Channel. """ - return Channel( - target, () if options is None else options, - None, - compression, - interceptors=interceptors) + return Channel(target, () if options is None else options, + None, + compression, + interceptors=interceptors) ################################### __all__ ################################# -__all__ = ('AioRpcError', 'RpcContext', 'Call', 'UnaryUnaryCall', 'UnaryStreamCall', - 'init_grpc_aio', 'Channel', 'UnaryUnaryMultiCallable', - 'ClientCallDetails', 'UnaryUnaryClientInterceptor', - 'InterceptedUnaryUnaryCall', 'insecure_channel', 'server') +__all__ = ('AioRpcError', 'RpcContext', 'Call', 'UnaryUnaryCall', + 'UnaryStreamCall', 'init_grpc_aio', 'Channel', + 'UnaryUnaryMultiCallable', 'ClientCallDetails', + 'UnaryUnaryClientInterceptor', 'InterceptedUnaryUnaryCall', + 'insecure_channel', 'server') diff --git a/src/python/grpcio/grpc/experimental/aio/_channel.py b/src/python/grpcio/grpc/experimental/aio/_channel.py index 9c91101c43d..3aa9fc07360 100644 --- a/src/python/grpcio/grpc/experimental/aio/_channel.py +++ b/src/python/grpcio/grpc/experimental/aio/_channel.py @@ -216,7 +216,8 @@ class Channel: else: self._unary_unary_interceptors = list( filter( - lambda interceptor: isinstance(interceptor, UnaryUnaryClientInterceptor), + lambda interceptor: isinstance(interceptor, + UnaryUnaryClientInterceptor), interceptors)) invalid_interceptors = set(interceptors) - set( @@ -249,9 +250,10 @@ class Channel: Returns: A UnaryUnaryMultiCallable value for the named unary-unary method. """ - return UnaryUnaryMultiCallable( - self._channel, _common.encode(method), request_serializer, - response_deserializer, self._unary_unary_interceptors) + return UnaryUnaryMultiCallable(self._channel, _common.encode(method), + request_serializer, + response_deserializer, + self._unary_unary_interceptors) def unary_stream( self, diff --git a/src/python/grpcio/grpc/experimental/aio/_interceptor.py b/src/python/grpcio/grpc/experimental/aio/_interceptor.py index 2476310fff0..00ea17924a4 100644 --- a/src/python/grpcio/grpc/experimental/aio/_interceptor.py +++ b/src/python/grpcio/grpc/experimental/aio/_interceptor.py @@ -118,11 +118,12 @@ class InterceptedUnaryUnaryCall(_base_call.UnaryUnaryCall): def __del__(self): self.cancel() - async def _invoke( - self, interceptors: Sequence[UnaryUnaryClientInterceptor], - method: bytes, timeout: Optional[float], request: RequestType, - request_serializer: SerializingFunction, - response_deserializer: DeserializingFunction) -> UnaryUnaryCall: + async def _invoke(self, interceptors: Sequence[UnaryUnaryClientInterceptor], + method: bytes, timeout: Optional[float], + request: RequestType, + request_serializer: SerializingFunction, + response_deserializer: DeserializingFunction + ) -> UnaryUnaryCall: """Run the RPC call wrapped in interceptors""" async def _run_interceptor( @@ -154,16 +155,16 @@ class InterceptedUnaryUnaryCall(_base_call.UnaryUnaryCall): return UnaryUnaryCallResponse(call_or_response) else: - return UnaryUnaryCall(request, - _timeout_to_deadline( - self._loop, - client_call_details.timeout), - self._channel, client_call_details.method, - request_serializer, response_deserializer) + return UnaryUnaryCall( + request, + _timeout_to_deadline(self._loop, + client_call_details.timeout), + self._channel, client_call_details.method, + request_serializer, response_deserializer) client_call_details = ClientCallDetails(method, timeout, None, None) - return await _run_interceptor( - iter(interceptors), client_call_details, request) + return await _run_interceptor(iter(interceptors), client_call_details, + request) def cancel(self) -> bool: if self._interceptors_task.done(): diff --git a/src/python/grpcio_tests/tests_aio/unit/interceptor_test.py b/src/python/grpcio_tests/tests_aio/unit/interceptor_test.py index f55c83eb48b..f97fbe171d3 100644 --- a/src/python/grpcio_tests/tests_aio/unit/interceptor_test.py +++ b/src/python/grpcio_tests/tests_aio/unit/interceptor_test.py @@ -52,8 +52,8 @@ class TestUnaryUnaryClientInterceptor(AioTestBase): server_target, _ = await start_test_server() # pylint: disable=unused-variable - async with aio.insecure_channel( - server_target, interceptors=interceptors) as channel: + async with aio.insecure_channel(server_target, + interceptors=interceptors) as channel: multicallable = channel.unary_unary( '/grpc.testing.TestService/UnaryCall', request_serializer=messages_pb2.SimpleRequest.SerializeToString, @@ -99,8 +99,8 @@ class TestUnaryUnaryClientInterceptor(AioTestBase): interceptor = StatusCodeOkInterceptor() server_target, server = await start_test_server() # pylint: disable=unused-variable - async with aio.insecure_channel( - server_target, interceptors=[interceptor]) as channel: + async with aio.insecure_channel(server_target, + interceptors=[interceptor]) as channel: # when no error StatusCode.OK must be observed multicallable = channel.unary_unary( @@ -129,8 +129,8 @@ class TestUnaryUnaryClientInterceptor(AioTestBase): interceptor = TimeoutInterceptor() server_target, server = await start_test_server() - async with aio.insecure_channel( - server_target, interceptors=[interceptor]) as channel: + async with aio.insecure_channel(server_target, + interceptors=[interceptor]) as channel: multicallable = channel.unary_unary( '/grpc.testing.TestService/UnaryCall', @@ -190,8 +190,8 @@ class TestUnaryUnaryClientInterceptor(AioTestBase): interceptor = RetryInterceptor() server_target, server = await start_test_server() - async with aio.insecure_channel( - server_target, interceptors=[interceptor]) as channel: + async with aio.insecure_channel(server_target, + interceptors=[interceptor]) as channel: multicallable = channel.unary_unary( '/grpc.testing.TestService/UnaryCall', @@ -329,8 +329,9 @@ class TestInterceptedUnaryUnaryCall(AioTestBase): server_target, _ = await start_test_server() # pylint: disable=unused-variable - async with aio.insecure_channel( - server_target, interceptors=[Interceptor()]) as channel: + async with aio.insecure_channel(server_target, + interceptors=[Interceptor() + ]) as channel: multicallable = channel.unary_unary( '/grpc.testing.TestService/UnaryCall', @@ -363,8 +364,9 @@ class TestInterceptedUnaryUnaryCall(AioTestBase): server_target, _ = await start_test_server() # pylint: disable=unused-variable - async with aio.insecure_channel( - server_target, interceptors=[Interceptor()]) as channel: + async with aio.insecure_channel(server_target, + interceptors=[Interceptor() + ]) as channel: multicallable = channel.unary_unary( '/grpc.testing.TestService/UnaryCall', @@ -407,8 +409,9 @@ class TestInterceptedUnaryUnaryCall(AioTestBase): server_target, _ = await start_test_server() # pylint: disable=unused-variable - async with aio.insecure_channel( - server_target, interceptors=[Interceptor()]) as channel: + async with aio.insecure_channel(server_target, + interceptors=[Interceptor() + ]) as channel: multicallable = channel.unary_unary( '/grpc.testing.TestService/UnaryCall', @@ -446,8 +449,9 @@ class TestInterceptedUnaryUnaryCall(AioTestBase): server_target, _ = await start_test_server() # pylint: disable=unused-variable - async with aio.insecure_channel( - server_target, interceptors=[Interceptor()]) as channel: + async with aio.insecure_channel(server_target, + interceptors=[Interceptor() + ]) as channel: multicallable = channel.unary_unary( '/grpc.testing.TestService/UnaryCall', @@ -478,8 +482,9 @@ class TestInterceptedUnaryUnaryCall(AioTestBase): server_target, _ = await start_test_server() # pylint: disable=unused-variable - async with aio.insecure_channel( - server_target, interceptors=[Interceptor()]) as channel: + async with aio.insecure_channel(server_target, + interceptors=[Interceptor() + ]) as channel: multicallable = channel.unary_unary( '/grpc.testing.TestService/UnaryCall',