Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python: Drop the custom .pyi plugin when generating Protobuf code. #429

Merged
merged 1 commit into from
Nov 10, 2023

Conversation

da-tanabe
Copy link
Contributor

@da-tanabe da-tanabe commented Nov 10, 2023

I added support for .pyi files for Protobuf code via a custom protoc 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 of protoc 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.

@da-tanabe da-tanabe force-pushed the python-drop-custom-pyi-plugin branch from 5068e51 to 4a8a6c0 Compare November 10, 2023 00:10
@da-tanabe da-tanabe marked this pull request as ready for review November 10, 2023 00:31
Copy link
Collaborator

@mschaef-da mschaef-da left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement.

@da-tanabe da-tanabe force-pushed the python-drop-custom-pyi-plugin branch from 4a8a6c0 to 1aae7ba Compare November 10, 2023 01:14
@da-tanabe da-tanabe enabled auto-merge November 10, 2023 01:21
@da-tanabe da-tanabe merged commit 6b2d975 into main Nov 10, 2023
@da-tanabe da-tanabe deleted the python-drop-custom-pyi-plugin branch November 10, 2023 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants