Make linters happy

pull/22925/head
Lidi Zheng 5 years ago
parent 028a7c4e79
commit ef6ff6dcfd
  1. 2
      src/python/grpcio/grpc/_common.py
  2. 2
      src/python/grpcio/grpc/experimental/__init__.py
  3. 13
      src/python/grpcio_tests/tests_aio/unit/server_interceptor_test.py

@ -15,9 +15,9 @@
import logging
import time
import six
import grpc
import six
from grpc._cython import cygrpc
_LOGGER = logging.getLogger(__name__)

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

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

Loading…
Cancel
Save