Skip to content

Commit 944efeb

Browse files
Allow None return from grpc.aio.ServerInterceptor.intercept_service
1 parent 6e3b4fa commit 944efeb

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

stubs/grpcio/grpc/aio/__init__.pyi

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,15 @@ class ServerInterceptor(metaclass=abc.ABCMeta):
375375
# This method (not the class) is generic over _TRequest and _TResponse
376376
# and the types must satisfy the no-op implementation of
377377
# `return await continuation(handler_call_details)`.
378+
# The return is Optional: per the runtime docstring, an interceptor
379+
# may return None to signal that the RPC is not serviced, and the
380+
# continuation propagates that None down the chain.
378381
@abc.abstractmethod
379382
async def intercept_service(
380383
self,
381-
continuation: Callable[[HandlerCallDetails], Awaitable[RpcMethodHandler[_TRequest, _TResponse]]],
384+
continuation: Callable[[HandlerCallDetails], Awaitable[RpcMethodHandler[_TRequest, _TResponse] | None]],
382385
handler_call_details: HandlerCallDetails,
383-
) -> RpcMethodHandler[_TRequest, _TResponse]: ...
386+
) -> RpcMethodHandler[_TRequest, _TResponse] | None: ...
384387

385388
# Multi-Callable Interfaces:
386389

0 commit comments

Comments
 (0)