diff --git a/stubs/grpcio/@tests/test_cases/check_server_interceptor.py b/stubs/grpcio/@tests/test_cases/check_server_interceptor.py index d5ef592a61ad..893ff591fb52 100644 --- a/stubs/grpcio/@tests/test_cases/check_server_interceptor.py +++ b/stubs/grpcio/@tests/test_cases/check_server_interceptor.py @@ -26,9 +26,9 @@ def intercept_service( class NoopAioInterceptor(grpc.aio.ServerInterceptor): async def intercept_service( self, - continuation: Callable[[grpc.HandlerCallDetails], Awaitable[grpc.RpcMethodHandler[RequestT, ResponseT]]], + continuation: Callable[[grpc.HandlerCallDetails], Awaitable[grpc.RpcMethodHandler[RequestT, ResponseT] | None]], handler_call_details: grpc.HandlerCallDetails, - ) -> grpc.RpcMethodHandler[RequestT, ResponseT]: + ) -> grpc.RpcMethodHandler[RequestT, ResponseT] | None: return await continuation(handler_call_details) diff --git a/stubs/grpcio/grpc/aio/__init__.pyi b/stubs/grpcio/grpc/aio/__init__.pyi index d05a8c3ddbe5..0704e5dea3d9 100644 --- a/stubs/grpcio/grpc/aio/__init__.pyi +++ b/stubs/grpcio/grpc/aio/__init__.pyi @@ -375,12 +375,15 @@ class ServerInterceptor(metaclass=abc.ABCMeta): # This method (not the class) is generic over _TRequest and _TResponse # and the types must satisfy the no-op implementation of # `return await continuation(handler_call_details)`. + # The return is Optional: per the runtime docstring, an interceptor + # may return None to signal that the RPC is not serviced, and the + # continuation propagates that None down the chain. @abc.abstractmethod async def intercept_service( self, - continuation: Callable[[HandlerCallDetails], Awaitable[RpcMethodHandler[_TRequest, _TResponse]]], + continuation: Callable[[HandlerCallDetails], Awaitable[RpcMethodHandler[_TRequest, _TResponse] | None]], handler_call_details: HandlerCallDetails, - ) -> RpcMethodHandler[_TRequest, _TResponse]: ... + ) -> RpcMethodHandler[_TRequest, _TResponse] | None: ... # Multi-Callable Interfaces: