danielgtaylor / danielgtaylor/python-betterproto
Add support for custom options
- Lenguaje dominante
- Python
- Estrellas
- 1.8k
- Forks
- 234
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
Custom options are a vanilla proto feature documented [here](https://developers.google.com/protocol-buffers/docs/proto#customoptions). I personally have a use case for them to apply constraints, similar to [protoc-gen-validate](https://github.com/envoyproxy/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:
1. 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 protocolbuffers/protobuf#3321.
2. `plugin.py` needs the ability to parse the custom options and somehow store them.
3. 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.
Guía de contribución
Línea de trabajo
Comienza con plugin.py y la carga de options proto alrededor de CodeGeneratorRequest.ParseFromString; después, lee la documentación enlazada sobre custom-options y el protobuf issue. Determina cómo deben analizarse, almacenarse y exponerse las opciones para la salida de Python generada; el trabajo estará terminado cuando se implemente un mecanismo genérico documentado y utilizable, y esté cubierto por pruebas.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- compilers, tooling
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100