-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Is your feature request related to a problem? Please describe.
Currently, the generated Python files are not accompanied by type stub files, which, in turn, forces users to disable type checking for some of their gRPC related code. The low-profile (and unmaintained?) package henribru/googleapis-common-protos-stubs provides stubs; however, it’s not been updated recently and its versioning does not lockstep with the actual Python package. It also requires users to take dependency on yet another third-party package that’s not officially maintained by gRPC/Google.
Describe the solution you'd like
I don’t see a problem to generate the type stub files as part of the official package. First, take a look at nipunn1313/mypy-protobuf which provides a protoc plugin to generate said type stub files alongside the Python files. The current proto compilation here
would need to be expanded:
- Install the plugin as per instructions
- Invoke the plugin
protoc --proto_path=/usr/src/protoc/include --proto_path=. \ --python_out=$PYTHON_PROTO_PATH \ --mypy_out=$PYTHON_PROTO_PATH \ --mypy_grpc_out=$PYTHON_PROTO_PATH \ $(find google -not -path "*/iam/*" -name "*.proto")
- Add the PEP-561 marker to the package.
Describe alternatives you've considered
The alternative is to either ignore missing imports, or use the aforementioned third-party package and bear the risks such a dependency brings.
Additional context
None.