make YAPF happy

pull/21455/head
Pau Freixes 5 years ago
parent 833df2b6c8
commit a2667b80c3
  1. 12
      src/python/grpcio/grpc/experimental/aio/__init__.py
  2. 10
      src/python/grpcio/grpc/experimental/aio/_channel.py
  3. 19
      src/python/grpcio/grpc/experimental/aio/_interceptor.py
  4. 41
      src/python/grpcio_tests/tests_aio/unit/interceptor_test.py

@ -52,8 +52,7 @@ def insecure_channel(
Returns:
A Channel.
"""
return Channel(
target, () if options is None else options,
return Channel(target, () if options is None else options,
None,
compression,
interceptors=interceptors)
@ -61,7 +60,8 @@ def insecure_channel(
################################### __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')

@ -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,

@ -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,
async def _invoke(self, interceptors: Sequence[UnaryUnaryClientInterceptor],
method: bytes, timeout: Optional[float],
request: RequestType,
request_serializer: SerializingFunction,
response_deserializer: DeserializingFunction) -> UnaryUnaryCall:
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,
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():

@ -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',

Loading…
Cancel
Save