danielgtaylor / danielgtaylor/python-betterproto

[Enhancement] Add a Clear method to the Message class for compatibility.

未关闭
#511 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
enhancement low priority
主要语言
Python
星标
1.8k
派生
234
PR 合并指标
30 天内没有已合并 PR

描述

When converting existing code to use this module over standard protobuf, one issue raised was the lack of `ParseFromString`. This has already been mentioned at #323, with a PR in the works at #336. However, this is blocked because it does not perform the same calls as the standard, namely, `Clear`. In my use of this module, i have worked around this issue by simply creating a new instance (which is always the default) instead of using an existing one, at which point just calling `parse` works fine.

Ideally, we'd need a `clear` function (preferably lowercase to match python syntax, but might want TitleCase for compatibility) on the abstract Message class and an implementation that resets all fields to their default values. We'd need to confirm that our implementation matches standard protobuf when it comes to user-defined default values.

to be clear, this isn't a bug, and it doesn't prevent the use of this module.
I'd look into addressing this myself but the logic used to set default values eludes me, at least at first glance.

贡献指南

打开贡献指南

调研方向

从抽象的 Message 类以及现有的 parse 和默认值逻辑开始;将它们的行为与标准 protobuf 进行比较,包括用户定义的默认值。当 clear 方法将所有字段重置为其默认值,并支持 #323 和 #336 中描述的兼容性工作时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
backend-api-design
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。