shabbyrobe / grpc-stubs

gRPC typing stubs for Python
MIT License
36 stars 21 forks source link

Wrong type hints for continuation in streaming interceptors #46

Closed arvidfm closed 1 year ago

arvidfm commented 1 year ago

Description of issue

grpc-stubs defines the continuation in interceptors to take a single request value (TRequest) as the second parameter:

https://github.com/shabbyrobe/grpc-stubs/blob/master/grpc-stubs/__init__.pyi#L527 https://github.com/shabbyrobe/grpc-stubs/blob/master/grpc-stubs/__init__.pyi#L537 https://github.com/shabbyrobe/grpc-stubs/blob/master/grpc-stubs/aio/__init__.pyi#L340 https://github.com/shabbyrobe/grpc-stubs/blob/master/grpc-stubs/aio/__init__.pyi#L353

But the examples in the official gRPC repository show that the continuations are expected to take iterators:

https://github.com/grpc/grpc/blob/d63c4709d162c4b8261848a6958e18486752a458/examples/python/interceptors/headers/generic_client_interceptor.py#L50 https://github.com/grpc/grpc/blob/d63c4709d162c4b8261848a6958e18486752a458/examples/python/interceptors/headers/generic_client_interceptor.py#L59

I think the second parameter of the continuation should have the same type as the third parameter of the intercept_stream_* functions, i.e. typing.Iterator[TRequest] for vanilla gRPC and typing.Union[typing.AsyncIterable[TRequest], typing.Iterable[TRequest]] for grpc.aio.

Minimum Reproducible Example

N/A

shabbyrobe commented 1 year ago

Thank you for the report. Unfortunately, without a minimum reproducible example (MRE), I will not be able to proceed with any fix for this. You are welcome to reopen this issue any time if you are able to supply an MRE.