protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

Code generator

Open eigenein opened this issue 6 years ago • 7 comments

For 3rd-party APIs people often have messages defined via *.proto files which are "ground truth". It requires additional work to keep Python data classes in sync with *.proto. Let's a make a "code generator" which translates *.proto files into *.py modules

eigenein avatar May 31 '19 12:05 eigenein

It'll be a good starting point to write the generator based on this project: https://github.com/dropbox/mypy-protobuf/blob/master/python/protoc-gen-mypy

The mypy style annotations in pyi files it generates are actually pretty close to your @dataclass decorated message classes.

reorx avatar Aug 03 '19 07:08 reorx

An off-topic suggestion BTW, since the package is called pure-protobuf, it's better to name this git project the same.

reorx avatar Aug 03 '19 07:08 reorx

Or generate *.proto files for others from the dataclasses?

tlc avatar Oct 27 '21 02:10 tlc

Is it still relevant? My project would benefit from such functionality, so I might try to implement it.

mbednarski avatar May 17 '22 14:05 mbednarski

@mbednarski I'd assume so. Feel free to submit a pull request anyway

eigenein avatar May 18 '22 11:05 eigenein

dumb q - is there already code to do the reverse? *.py -> *.proto (for sharing outward?)

EricCousineau-TRI avatar Jul 14 '22 23:07 EricCousineau-TRI

@EricCousineau-TRI no, there wasn't such a thing

eigenein avatar Jul 20 '22 14:07 eigenein