proper support of __get_pydantic_core_schema__
还没有人认领这个 Issue。
评估
调研方向
从 src/betterproto/enum.py 中链接属性限制附近的部分开始,检查生成的 Enum 类如何处理 setattr。将该行为与 issue 中链接的 Pydantic 自定义类型指南进行比较,然后检查允许 get_pydantic_core_schema 是否会影响其他 Enum 路径。完成标准是私有集成方法能够正常工作,同时不允许无关的公共属性。
由索引模型根据 Issue 内容生成。
描述
Summary
I'd like to dynamically add non-public methods to my Enums
What is the feature request for?
The core library
The Problem
I'm mixing up betterproto.Enum with pydantic classes for easier conversion between my database objects and protobuf messages. To use pydantic, I have to add validator based on this instruction. Thus, I decided to dynamically add a class method to a generated betterproto.Enum. However, betterproto.enum does not allow it by this
Are there any other parts of the code affected by adding a custom function __get_pydantic_core_schema__ to my generated Enum?
The Ideal Solution
I'd like __set_attr__ to accept new attributes if the new attributes are private (i.e.,starting with __) I can contribute if this direction is acceptable.
The Current Solution
If no other solutions, I will fork this repo and just remove the constraint. I don't like to fork for a hack.
- 主要语言
- Python
- 星标
- 1.8k
- 派生
- 235
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
danielgtaylor/python-betterproto 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 55/100
-
难度 5/5 一周以上 新手友好度 15/100
-
bug investigation needed
难度 3/5 1-2 天 新手友好度 42/100
-
bug investigation needed
难度 3/5 1-2 天 新手友好度 45/100
-
bug investigation needed
难度 4/5 3-5 天 新手友好度 38/100
danielgtaylor/python-betterproto#676 · 3 条评论 ·
查看 danielgtaylor/python-betterproto 的全部 Issue
相似的 Issue
-
[oblt-aw][autodoc] Update workflow docs for gh-aw v0.92.5 and detector permission scope可能已有人在做 @github-actions 今天认领。 未关闭
难度 1/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
roadmap-100
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
comp/tools P2 tool/browser tool/file type/bug
难度 2/5 1-3 小时 新手友好度 75/100
NousResearch/hermes-agent#143418 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
python-hyper/uritemplate#164 ·