danielgtaylor / danielgtaylor/python-betterproto

Add support for custom options

オープン
#119 コメント 18 件 リアクション 6 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Python
スター
1.8k
フォーク
234
PR マージ指標
30日以内にマージされた PR はありません

説明

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:

  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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

plugin.py と CodeGeneratorRequest.ParseFromString 周辺の options proto の読み込みから始め、次にリンクされている custom-options のドキュメントと protobuf issue を読んでください。生成される Python 出力のために、options をどのように解析、保存、公開すべきかを判断してください。文書化された使用可能な汎用メカニズムが実装され、テストでカバーされた時点で作業は完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
compilers, tooling
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。