Open
Description
Custom options are a vanilla proto feature documented here. I personally have a use case for them to apply constraints, similar to protoc-gen-validate. I think supporting generic custom options would be a great addition to python-betterproto.
In order for this to happen, I see a couple changes that would be needed:
- The options proto needs to be compiled by protoc and imported into the namespace from which
CodeGeneratorRequest. ParseFromString
is called. This req is documented in Python ParseFromString not parsing custom options protocolbuffers/protobuf#3321. plugin.py
needs the ability to parse the custom options and somehow store them.- We'd need to figure out how to use the custom options: Python has no concept of applying "options" (aside from comments). There are many mechanisms that could be employed (getters/setters, pydantic, comments, etc.). My feeling is that to cover all use cases,
plugin.py
would need to be made extendable so that individual implementations can decide how to parse custom options and how to use them in the generation of the output.py
files.
Is there any interest in this? I'd be willing to try and work on something.
Metadata
Metadata
Assignees
Labels
No labels