danielgtaylor / danielgtaylor/python-betterproto
`to_dict` or `to_pydict` miss integer and boolean fields
- 主要言語
- Python
- スター
- 1.8k
- フォーク
- 234
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
when i use `to_dict` or `to_pydict` function to serialize message, `False` and `0` values are not work for boolean and integer fields.
here is the sample code:
```python3
from dataclasses import dataclass
import betterproto
@dataclass
class Greeting(betterproto.Message):
"""Greeting represents a message you can tell a user."""
int_field: int = betterproto.int32_field(1)
bool_field: bool = betterproto.bool_field(2)
if __name__ == "__main__":
greeting = Greeting(
int_field=0,
bool_field=False
)
print(greeting.to_pytdict())
greeting.int_field = 1
greeting.bool_field = True
print(greeting.to_pydict())
```
and output is:
```
{}
{'intField': 1, 'boolField': True}
```
python version: 3.8
betterproto version: 2.0.0b5
コントリビューションガイド
調査の方向性
まず Python 3.8 で Greeting の例を再現し、デフォルト値の整数フィールドおよびブールフィールドに対する to_pydict 出力を truthy 値に対する出力と比較します。to_dict または to_pydict のシリアライズ経路を追跡します。0 と False が既存の動作を変更せずに正しくシリアライズされれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend-api-design
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100