-
Notifications
You must be signed in to change notification settings - Fork 609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ Compatible with pydantic 2.0 #1826
Conversation
… provided by nonebot
审阅者指南 by Sourcery这个拉取请求将项目升级为与 pydantic 2.0 兼容。主要更改包括将 显示更新后的 ShopParam 模型的类图classDiagram
class ShopParam {
+text: str
+session: Uninfo|None
+message: UniMsg
+send_success_msg: ClassVar[bool]
+max_num_limit: ClassVar[int]
+extra_data: ClassVar[dict[str, Any]]
+to_dict(kwargs): dict
}
class Config {
+arbitrary_types_allowed: bool
}
ShopParam --> Config
note for ShopParam "更新为对静态字段使用 ClassVar
并为额外参数添加 extra_data"
显示 BaseModel 变更的类图classDiagram
class BaseModel {
+to_dict(kwargs): dict
}
note for BaseModel "将 dict() 替换为 to_dict()
内部使用 model_dump()"
class ConfigModel
class ConfigGroup
class BaseBlock
class PluginExtraData
BaseModel <|-- ConfigModel
BaseModel <|-- ConfigGroup
BaseModel <|-- BaseBlock
BaseModel <|-- PluginExtraData
文件级别变更
针对关联问题的评估
提示和命令与 Sourcery 交互
自定义您的体验访问您的仪表板以:
获取帮助Original review guide in EnglishReviewer's Guide by SourceryThis pull request upgrades the project to be compatible with pydantic 2.0. The main changes include replacing Class diagram showing updated ShopParam modelclassDiagram
class ShopParam {
+text: str
+session: Uninfo|None
+message: UniMsg
+send_success_msg: ClassVar[bool]
+max_num_limit: ClassVar[int]
+extra_data: ClassVar[dict[str, Any]]
+to_dict(kwargs): dict
}
class Config {
+arbitrary_types_allowed: bool
}
ShopParam --> Config
note for ShopParam "Updated to use ClassVar for static fields
and added extra_data for additional parameters"
Class diagram showing BaseModel changesclassDiagram
class BaseModel {
+to_dict(kwargs): dict
}
note for BaseModel "Replaced dict() with to_dict()
which uses model_dump() internally"
class ConfigModel
class ConfigGroup
class BaseBlock
class PluginExtraData
BaseModel <|-- ConfigModel
BaseModel <|-- ConfigGroup
BaseModel <|-- BaseBlock
BaseModel <|-- PluginExtraData
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嘿 @BalconyJH - 我已经审查了你的更改,看起来非常棒!
以下是我在审查期间查看的内容
- 🟡 一般性问题:发现1个问题
- 🟢 安全性:一切看起来都很好
- 🟢 测试:一切看起来都很好
- 🟢 复杂性:一切看起来都很好
- 🟢 文档:一切看起来都很好
帮助我变得更有用!请在每条评论上点击 👍 或 👎,我将使用这些反馈来改进你的评论。
Original comment in English
Hey @BalconyJH - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
@@ -91,7 +96,7 @@ class ConfigGroup(BaseModel): | |||
"""模块名""" | |||
name: str | None = None | |||
"""插件名""" | |||
configs: dict[str, ConfigModel] = {} | |||
configs: dict[str, ConfigModel] = defaultdict() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
问题(bug风险): 没有default_factory参数的defaultdict()将引发TypeError
Original comment in English
issue (bug_risk): defaultdict() without a default_factory parameter will raise TypeError
30b00b7
to
87756c5
Compare
🚨 Make pyright happy ♻️ Remove unused adapter
…o to version 0.25.1 and adjust dependencies
87756c5
to
15fd196
Compare
✨ Compatible with pydantic 2.0
主要变更
此PR主要解决了 zhenxun_bot 代码库与 pydantic 2.0 的兼容性问题(Resolved #1825)。
依赖变动
功能增强
register_use
函数,新增支持send_success_msg
和max_num_limit
的关键字参数ShopParam
模型中添加extra_data
字段,用于存储额外数据技术改进
dict()
方法调用更新为to_dict()
,以适配 pydantic 2.0 的新APIShopParam
和register_use
的变更保持一致杂项
tool.poetry.dev-dependencies
更新为tool.poetry.group.dev.dependencies
,以适配最新的 poetry 规范标签
Original description in English
✨ Compatible with pydantic 2.0
Major Changes
This PR addresses the compatibility issues between zhenxun_bot codebase and pydantic 2.0 (Resolved #1825).
Dependency Updates
Enhancements
register_use
function to support keyword arguments forsend_success_msg
andmax_num_limit
extra_data
field toShopParam
model for storing additional dataTechnical Improvements
dict()
method calls toto_dict()
to align with pydantic 2.0 APIMiscellaneous
tool.poetry.dev-dependencies
totool.poetry.group.dev.dependencies
to comply with latest poetry specificationLabels