protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Python pyi files generation description

Open k-wozniak opened this issue 2 years ago • 2 comments

I have recently learned that Protobuf compiler (protoc) for Python is able to generate .pyi files, which are very helpful, as the standard .py files are not designed to be readable.

It took a significant effort to find this feature after searching for an easier way of dealing with generated python files / IDE support for them.

Would it be possible to add a description of this feature to the Python tutorial section? https://developers.google.com/protocol-buffers/docs/pythontutorial

k-wozniak avatar Nov 15 '22 10:11 k-wozniak

I was trying to find the same. How and where did you find it? @k-wozniak

rudradesai200 avatar Dec 02 '22 00:12 rudradesai200

I was trying to find the same. How and where did you find it? @k-wozniak

Pure luck. My team and I were using protobuf with Python, and I just could not believe that this is the only option. At some point, I went through the release history and v3.20.0 describes the support and how to generate .pyi files.

Protoc is now able to generate python stubs (.pyi) with --pyi_out

Example:

protoc -I=..\InputDirectory --python_out=..\PythonPyOutputDirectory --pyi_out=..\PythonPyiOutputDirectory ..\CompilerInput\proto_to_build.proto

k-wozniak avatar Dec 02 '22 10:12 k-wozniak

@rudradesai200 , I create a repo for this based on @k-wozniak 's code. Feel free to use it: https://github.com/airbots/grafana-mimir-python-client

airbots avatar May 25 '23 19:05 airbots

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

github-actions[bot] avatar Dec 28 '23 10:12 github-actions[bot]

@github-actions "a comment"

andreymal avatar Dec 28 '23 10:12 andreymal

Thanks for the update to the issue. I'll keep this in my planned work.

Logofile avatar Dec 28 '23 14:12 Logofile

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

github-actions[bot] avatar Mar 29 '24 10:03 github-actions[bot]

@github-actions "a comment" 🙄

andreymal avatar Mar 29 '24 14:03 andreymal

I'm working on an update right now, @andreymal . Thanks for your patience, and for keeping the issue open!

Logofile avatar Mar 29 '24 15:03 Logofile

https://github.com/protocolbuffers/protocolbuffers.github.io/pull/132 addresses this missing information. Thanks for your help in identifying and resolving this.

Logofile avatar Apr 08 '24 12:04 Logofile