Protoc by default doesn't provide typings or stub files for python. These are greatly improving code corectness, speed of development and helps a programmer to deliver higher quality product for lesser time.
This plugin is providing declarations in stub file of:
- message interface
- fields type
- constructor interface
- enumerator values
- nested messages interfaces
stored into {PROTO_NAME}_pb2.pyi
and
- servicer interface
- stub interface
-
add_{SERVICER_NAME}_to_service
method interface
stored into {PROTO_NAME}_pb2_grpc.pyi
.
To install this plugin, just run pip install
with path to this repository:
$ sudo pip install ./
To use this plugin, just simple use python_typings_out
parameter in protoc
command, which can be use with standard python_out
and grpc_python_out
parameters:
$ protoc --python_out=./proto --grpc_python_out=./proto --python_typings_out=./proto --grpc_python_typings_out=./proto -I./proto ./proto/buffer.proto
The example was built with these options in a project directory:
$ protoc ./example/application.proto --python_typings_out=./example --python_out=./example --grpc_python_typings_out=./example --grpc_python_out=./example -I${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis -I./example
- extensible template background for both plugins
- working simple typing generator, that was protoc missing
- setup.py
- generating proper type imports
- tests