python: Drop the custom .pyi plugin when generating Protobuf code. #429
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I added support for
.pyi
files for Protobuf code via a customprotoc
plugin (#271) back in August 2021. Unfortunately, just seven short months later,protoc
added support for generating Python stubs with--pyi_out
in Protocol Buffers v3.20.0.I just noticed it's a thing now, so switch to it instead of continuing to rely on the hand-rolled one I had to write. Unfortunately stubs are only generated for Protobuf messages—I still need to generate typing files for gRPC stubs myself for now.
There are some annoying things that mypy doesn't like about Protobuf's
.pyi
files, so post-process the.pyi
files out ofprotoc
and add# type: ignore
. It might be a better solution long-term to tell mypy to ignore all of the generated protoc code if/when gRPC stubs also gain the ability to have typing files generated for them natively.