-
Notifications
You must be signed in to change notification settings - Fork 75
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
[Feature]: Support generate pyi for python binding #100
Comments
How is that going to be different from the Python binding (python_out) we already have? |
@yurishkuro You can refer to this commit, I've introduced a portion of the pyi file into the project so that when using the relevant message class, the IDE (and of course VSCode) will be able to understand what properties the class has and give code hints. |
You would get the same effect by introducing plain |
Not quite right, according to PEP 484, pyi files will provide type references so that type checking tools can work. This approach does not require modification of the code being executed, and therefore does not break any compatibility (in fact, Python's type hints have gone through several changes). Here's an example of a static analysis I found in the Internet: In the official example, pyi files are also provided. https://github.com/grpc/grpc/blob/master/examples/python/helloworld/helloworld_pb2.pyi |
Type hints are part of Python language. |
Type hints can both be inlined in the python code, as well as separately (including in separate packages) in They are described in the pep link that @Wh1isper provided above, in the following section: https://peps.python.org/pep-0484/#stub-files |
Requirement
In protobuf 3.20.0, we can use
protoc
to generate pyi for python's type hint. This has been pulled into a released gRPC version(>= 1.48.2, as metioned here: grpc/grpc#29650 (comment))Note that the current version of grpc is 1.35.0, so in the next upgrade, if the version is met, hopefully the relevant builds will be added.
Problem
pyi will provide python users with a great programming experience and enable type-checking tools.
Proposal
No response
Open questions
No response
The text was updated successfully, but these errors were encountered: