@@ -45,8 +45,6 @@ class AioRpcError(RpcError):
4545
4646# Create Client:
4747
48- class ClientInterceptor (metaclass = abc .ABCMeta ): ...
49-
5048def insecure_channel (
5149 target : str ,
5250 options : _Options | None = None ,
@@ -288,7 +286,7 @@ class InterceptedUnaryUnaryCall(_InterceptedCall[_TRequest, _TResponse], metacla
288286 def __await__ (self ) -> Generator [Incomplete , None , _TResponse ]: ...
289287 def __init__ (
290288 self ,
291- interceptors : Sequence [UnaryUnaryClientInterceptor [ _TRequest , _TResponse ] ],
289+ interceptors : Sequence [UnaryUnaryClientInterceptor ],
292290 request : _TRequest ,
293291 timeout : float | None ,
294292 metadata : Metadata ,
@@ -304,7 +302,7 @@ class InterceptedUnaryUnaryCall(_InterceptedCall[_TRequest, _TResponse], metacla
304302 # pylint: disable=too-many-arguments
305303 async def _invoke (
306304 self ,
307- interceptors : Sequence [UnaryUnaryClientInterceptor [ _TRequest , _TResponse ] ],
305+ interceptors : Sequence [UnaryUnaryClientInterceptor ],
308306 method : bytes ,
309307 timeout : float | None ,
310308 metadata : Metadata | None ,
@@ -316,42 +314,53 @@ class InterceptedUnaryUnaryCall(_InterceptedCall[_TRequest, _TResponse], metacla
316314 ) -> UnaryUnaryCall [_TRequest , _TResponse ]: ...
317315 def time_remaining (self ) -> float | None : ...
318316
319- class UnaryUnaryClientInterceptor (Generic [_TRequest , _TResponse ], metaclass = abc .ABCMeta ):
317+ class ClientInterceptor (metaclass = abc .ABCMeta ): ...
318+
319+ class UnaryUnaryClientInterceptor (ClientInterceptor , metaclass = abc .ABCMeta ):
320+ # This method (not the class) is generic over _TRequest and _TResponse.
320321 @abc .abstractmethod
321322 async def intercept_unary_unary (
322323 self ,
323324 # XXX: See equivalent function in grpc types for notes about continuation:
324- continuation : Callable [[ClientCallDetails , _TRequest ], UnaryUnaryCall [_TRequest , _TResponse ]],
325+ continuation : Callable [[ClientCallDetails , _TRequest ], Awaitable [ UnaryUnaryCall [_TRequest , _TResponse ] ]],
325326 client_call_details : ClientCallDetails ,
326327 request : _TRequest ,
327- ) -> _TResponse : ...
328+ ) -> _TResponse | UnaryUnaryCall [ _TRequest , _TResponse ] : ...
328329
329- class UnaryStreamClientInterceptor (Generic [_TRequest , _TResponse ], metaclass = abc .ABCMeta ):
330+ class UnaryStreamClientInterceptor (ClientInterceptor , metaclass = abc .ABCMeta ):
331+ # This method (not the class) is generic over _TRequest and _TResponse.
330332 @abc .abstractmethod
331333 async def intercept_unary_stream (
332334 self ,
333- continuation : Callable [[ClientCallDetails , _TRequest ], UnaryStreamCall [_TRequest , _TResponse ]],
335+ continuation : Callable [[ClientCallDetails , _TRequest ], Awaitable [ UnaryStreamCall [_TRequest , _TResponse ] ]],
334336 client_call_details : ClientCallDetails ,
335337 request : _TRequest ,
336- ) -> AsyncIterable [_TResponse ] | UnaryStreamCall [_TRequest , _TResponse ]: ...
338+ ) -> AsyncIterator [_TResponse ] | UnaryStreamCall [_TRequest , _TResponse ]: ...
337339
338- class StreamUnaryClientInterceptor (Generic [_TRequest , _TResponse ], metaclass = abc .ABCMeta ):
340+ class StreamUnaryClientInterceptor (ClientInterceptor , metaclass = abc .ABCMeta ):
341+ # This method (not the class) is generic over _TRequest and _TResponse.
339342 @abc .abstractmethod
340343 async def intercept_stream_unary (
341344 self ,
342- continuation : Callable [[ClientCallDetails , _TRequest ], StreamUnaryCall [_TRequest , _TResponse ]],
345+ continuation : Callable [
346+ [ClientCallDetails , AsyncIterable [_TRequest ] | Iterable [_TRequest ]], Awaitable [StreamUnaryCall [_TRequest , _TResponse ]]
347+ ],
343348 client_call_details : ClientCallDetails ,
344349 request_iterator : AsyncIterable [_TRequest ] | Iterable [_TRequest ],
345- ) -> AsyncIterable [ _TResponse ] | UnaryStreamCall [_TRequest , _TResponse ]: ...
350+ ) -> _TResponse | StreamUnaryCall [_TRequest , _TResponse ]: ...
346351
347- class StreamStreamClientInterceptor (Generic [_TRequest , _TResponse ], metaclass = abc .ABCMeta ):
352+ class StreamStreamClientInterceptor (ClientInterceptor , metaclass = abc .ABCMeta ):
353+ # This method (not the class) is generic over _TRequest and _TResponse.
348354 @abc .abstractmethod
349355 async def intercept_stream_stream (
350356 self ,
351- continuation : Callable [[ClientCallDetails , _TRequest ], StreamStreamCall [_TRequest , _TResponse ]],
357+ continuation : Callable [
358+ [ClientCallDetails , AsyncIterable [_TRequest ] | Iterable [_TRequest ]],
359+ Awaitable [StreamStreamCall [_TRequest , _TResponse ]],
360+ ],
352361 client_call_details : ClientCallDetails ,
353362 request_iterator : AsyncIterable [_TRequest ] | Iterable [_TRequest ],
354- ) -> AsyncIterable [_TResponse ] | StreamStreamCall [_TRequest , _TResponse ]: ...
363+ ) -> AsyncIterator [_TResponse ] | StreamStreamCall [_TRequest , _TResponse ]: ...
355364
356365# Server-Side Interceptor:
357366
0 commit comments