eigenein / protobuf

Python implementation of Protocol Buffers with dataclass-based schemaʼs
https://eigenein.github.io/protobuf/
MIT License
253 stars 22 forks source link

Code generator #64

Open eigenein opened 5 years ago

eigenein commented 5 years ago

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

reorx commented 5 years ago

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 commented 5 years ago

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

tlc commented 2 years ago

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

mbednarski commented 2 years ago

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

eigenein commented 2 years ago

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

EricCousineau-TRI commented 2 years ago

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

eigenein commented 2 years ago

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