protobuf
protobuf copied to clipboard
Python: Add type hints and py.typed
It'd be great if the Python protobuf package included a py.typed file (indicating to mypy and such that the package has type hints), and adding type hints to the codebase.
At the moment, I'm using the types-protobuf package but would prefer to have the types integrated.
I realize this is a large undertaking. Just opening this issue up to refer back to it.
What types-protobuf package do you mean?
Have you tried to use protoc generate python stubs (.pyi) with --pyi_out
Thanks for getting back to me! I'm talking about stubs for the protobuf package itself, not generated stubs.
There's no type hints here or py.typed file: https://github.com/protocolbuffers/protobuf/tree/main/python/google/protobuf
Sounds reasonable. We do have .pyi file in google internal for message.py, text_format.py and well_known_types.py. Will see if we can release them into opensource too
Great, thank you!
I have the same suggestion as @gitpushdashf but let me rephrase it. You have generic Protos, that you are compiling and including in the protobuf package like https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/wrappers.proto and other protos defined in that folder. Could you include stubs for them to the package? Since that code is already generated, the only thing left is adding *.pyi files to the package.
Sounds reasonable. We do have .pyi file in google internal for message.py, text_format.py and well_known_types.py. Will see if we can release them into opensource too
Hello, would you please help me ? Have yet public into opensource now? I have found that there is no type hints for internal apis when use functions of protobuf lib.
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.
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 reopen it.
This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.