d5h-foss / grpc-interceptor

Simplified Python gRPC interceptors
MIT License
136 stars 21 forks source link

AttributeError: module 'grpc' has no attribute 'Compression' #15

Closed aipave closed 2 years ago

aipave commented 2 years ago

File "/data/svr/py_signin/venv_svr_signin/lib/python3.7/site-packages/grpc_interceptor/client.py", line 15, in _ClientCallDetailsFields compression: Optional[grpc.Compression] AttributeError: module 'grpc' has no attribute 'Compression'

class _ClientCallDetailsFields(NamedTuple): method: str timeout: Optional[float] metadata: Optional[Sequence[Tuple[str, Union[str, bytes]]]] credentials: Optional[grpc.CallCredentials] wait_for_ready: Optional[bool] compression: Optional[grpc.Compression]

after add an annotation, solve this error

` class _ClientCallDetailsFields(NamedTuple): method: str timeout: Optional[float] metadata: Optional[Sequence[Tuple[str, Union[str, bytes]]]] credentials: Optional[grpc.CallCredentials] wait_for_ready: Optional[bool]

compression: Optional[grpc.Compression]

`

grpc version is: grpcio ==1.20.1, even thougn I upgrade versino to 1.45.0 it has the same error.

d5h commented 2 years ago

It looks like grpc.Compression was added in grpcio version 1.23.0: https://github.com/grpc/grpc/releases/tag/v1.23.0. So I'm not sure why updating wouldn't solve the problem.

I'll make a fix for this anyway, because I think things should work even on older versions of grpcio with the fix.

d5h commented 2 years ago

This should be fixed in 0.14.1, so please let me know if you continue to see issues.