danielgtaylor / danielgtaylor/python-betterproto
nested empty types not in to_dict
- 主要言語
- Python
- スター
- 1.8k
- フォーク
- 234
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
I am not sure if I am wrong here but when executing this:
```python
from dataclasses import dataclass
import betterproto
@dataclass
class Inner(betterproto.Message):
inner1: str = betterproto.string_field(1)
inner2: str = betterproto.string_field(2)
@dataclass
class Test(betterproto.Message):
name: str = betterproto.string_field(1)
inner: "Inner" = betterproto.message_field(2)
test = Test(name='123', inner=Inner())
print(test.to_json())
```
I receive the output `{"name": "123"}`. I would expect the output to be`{"name": "123", inner:{}}`.
Of course there is a similar issue with the `to_dict` function
コントリビューションガイド
調査の方向性
まず提供されている Python の再現コードを実行し、その後 Message.to_json と Message.to_dict の実装を調べます。初期化済みの空の Inner メッセージが両方の出力で空のネストされたオブジェクトとして保持され、既存の name フィールドが変更されない状態になれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100