From ef6ff6dcfde7e65f114650c57151b73ea87e9ea1 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Tue, 12 May 2020 10:43:12 -0700 Subject: [PATCH] Make linters happy --- src/python/grpcio/grpc/_common.py | 2 +- src/python/grpcio/grpc/experimental/__init__.py | 2 +- .../tests_aio/unit/server_interceptor_test.py | 13 ++++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/python/grpcio/grpc/_common.py b/src/python/grpcio/grpc/_common.py index 3c455678ff0..27fc80b1498 100644 --- a/src/python/grpcio/grpc/_common.py +++ b/src/python/grpcio/grpc/_common.py @@ -15,9 +15,9 @@ import logging import time +import six import grpc -import six from grpc._cython import cygrpc _LOGGER = logging.getLogger(__name__) diff --git a/src/python/grpcio/grpc/experimental/__init__.py b/src/python/grpcio/grpc/experimental/__init__.py index 83f0b860eb7..083a7638486 100644 --- a/src/python/grpcio/grpc/experimental/__init__.py +++ b/src/python/grpcio/grpc/experimental/__init__.py @@ -92,7 +92,7 @@ def wrap_server_method_handler(wrapper, handler): if not handler.request_streaming: if not handler.response_streaming: # NOTE(lidiz) _replace is a public API: - # https://docs.python.org/dev/library/collections.html#collections.somenamedtuple._replace + # https://docs.python.org/dev/library/collections.html return handler._replace(unary_unary=wrapper(handler.unary_unary)) else: return handler._replace(unary_stream=wrapper(handler.unary_stream)) diff --git a/src/python/grpcio_tests/tests_aio/unit/server_interceptor_test.py b/src/python/grpcio_tests/tests_aio/unit/server_interceptor_test.py index ad56a44aa1c..c93fe1b7b0e 100644 --- a/src/python/grpcio_tests/tests_aio/unit/server_interceptor_test.py +++ b/src/python/grpcio_tests/tests_aio/unit/server_interceptor_test.py @@ -196,19 +196,22 @@ class TestServerInterceptor(AioTestBase): # Get the actual handler handler = await continuation(handler_call_details) - def wrap_handler(handler: grpc.RpcMethodHandler): + def wrapper(behavior: Callable[ + [messages_pb2.SimpleRequest, aio. + ServerInterceptor], messages_pb2.SimpleResponse]): - @functools.wraps(handler) + @functools.wraps(behavior) async def wrapper(request: messages_pb2.SimpleRequest, - context: aio.ServicerContext): + context: aio.ServicerContext + ) -> messages_pb2.SimpleResponse: if request.response_size not in cache_store: - cache_store[request.response_size] = await handler( + cache_store[request.response_size] = await behavior( request, context) return cache_store[request.response_size] return wrapper - return wrap_server_method_handler(wrap_handler, handler) + return wrap_server_method_handler(wrapper, handler) # Constructs a server with the cache interceptor server, stub = await _create_server_stub_pair(