Skip to content
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

🚨 Make pyright happy #1840

Merged
merged 1 commit into from
Jan 26, 2025
Merged

🚨 Make pyright happy #1840

merged 1 commit into from
Jan 26, 2025

Conversation

BalconyJH
Copy link
Collaborator

No description provided.

@BalconyJH BalconyJH requested a review from HibiKier January 26, 2025 19:32
Copy link
Contributor

sourcery-ai bot commented Jan 26, 2025

Here's the translation to Chinese:

审阅指南 by Sourcery

此拉取请求修改了多个 BaseModel 类,使用 field(default_factory=list)field(default_factory=dict) 替换列表和字典属性的可变默认值。此更改确保每个类的实例都获得独立的列表或字典,防止实例之间意外共享数据。

更新的类图:Command、ConfigGroup、Task、PluginExtraData、BuildMatData、Goods、ReqResult、BotSetting 和 FileInfo

classDiagram
    class Command {
        - list~str~ params
        - list~Example~ examples
    }
    class ConfigGroup {
        - dict~str, ConfigModel~ configs
    }
    class Task {
        - list check_args
    }
    class PluginExtraData {
        - list~Command~ commands
        - set~str~ aliases
    }
    class BuildMatData {
        - list~int|float~ data
        - list~str~ x_index
        - list~int|float~ y_index
        - list~str~ bar_color
    }
    class Goods {
        - list~Callable~ before_handle
        - list~Callable~ after_handle
        - dict~str, str~ kwargs
    }
    class ReqResult {
        - list~FriendRequestResult~ friend
        - list~GroupRequestResult~ group
    }
    class BotSetting {
        - dict~str, list~str~~ platform_superusers
        - dict~str, str~ qbot_id_data
    }
    class FileInfo {
        - list~FileInfo~ files
    }
    note for Command "更新为对 params 和 examples 使用 field(default_factory=list)"
    note for ConfigGroup "更新为对 configs 使用 field(default_factory=dict)"
    note for Task "更新为对 check_args 使用 field(default_factory=list)"
    note for PluginExtraData "更新为对 commands 使用 field(default_factory=list),对 aliases 使用 field(default_factory=set)"
    note for BuildMatData "更新为对 data、x_index、y_index 和 bar_color 使用 field(default_factory=list)"
    note for Goods "更新为对 before_handle 和 after_handle 使用 field(default_factory=list),对 kwargs 使用 field(default_factory=dict)"
    note for ReqResult "更新为对 friend 和 group 使用 field(default_factory=list)"
    note for BotSetting "更新为对 platform_superusers 和 qbot_id_data 使用 field(default_factory=dict)"
    note for FileInfo "更新为对 files 使用 field(default_factory=list)"
Loading

文件级别变更

变更 详情 文件
将 BaseModel 类中列表属性的可变默认值替换为 field(default_factory=list)
  • Command 类中将 params: list[str] = [] 更改为 params: list[str] = field(default_factory=list)
  • Command 类中将 examples: list[Example] = [] 更改为 examples: list[Example] = field(default_factory=list)
  • 其他类似更改...
zhenxun/configs/utils/__init__.py
zhenxun/utils/_build_mat.py
zhenxun/utils/decorator/shop.py
zhenxun/builtin_plugins/shop/_data_source.py
zhenxun/builtin_plugins/web_ui/api/tabs/manage/model.py
zhenxun/utils/github_utils/models.py
将 BaseModel 类中字典属性的可变默认值替换为 field(default_factory=dict)
  • ConfigGroup 类中将 configs: dict[str, ConfigModel] = defaultdict() 更改为 configs: dict[str, ConfigModel] = field(default_factory=dict)
  • 其他类似更改...
zhenxun/configs/utils/__init__.py
zhenxun/utils/decorator/shop.py
zhenxun/configs/config.py
将 BaseModel 类中集合属性的可变默认值替换为 field(default_factory=set)
  • PluginExtraData 类中将 aliases: set[str] = set() 更改为 aliases: set[str] = field(default_factory=set)
zhenxun/configs/utils/__init__.py
将 BaseModel 类中带有默认值的列表属性替换为 field(default_factory=lambda: ['*'])
  • BuildMatData 类中将 bar_color: list[str] = ['*'] 更改为 bar_color: list[str] = field(default_factory=lambda: ['*'])
zhenxun/utils/_build_mat.py

提示和命令

与 Sourcery 交互

  • 触发新的审阅: 在拉取请求中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审阅评论。
  • 从审阅评论生成 GitHub 问题: 通过回复审阅评论要求 Sourcery 创建问题。也可以用 @sourcery-ai issue 回复审阅评论来创建问题。
  • 生成拉取请求标题: 在拉取请求标题的任何位置写 @sourcery-ai 以随时生成标题。也可以在拉取请求中评论 @sourcery-ai title 以随时(重新)生成标题。
  • 生成拉取请求摘要: 在拉取请求正文的任何位置写 @sourcery-ai summary 以在想要的位置生成 PR 摘要。也可以在拉取请求中评论 @sourcery-ai summary 以随时(重新)生成摘要。
  • 生成审阅指南: 在拉取请求中评论 @sourcery-ai guide 以随时(重新)生成审阅指南。
  • 解决所有 Sourcery 评论: 在拉取请求中评论 @sourcery-ai resolve 以解决所有 Sourcery 评论。如果已经处理了所有评论,不想再看到它们,这很有用。
  • 取消所有 Sourcery 审阅: 在拉取请求中评论 @sourcery-ai dismiss 以取消所有现有的 Sourcery 审阅。特别适用于想要重新开始新的审阅 - 别忘了评论 @sourcery-ai review 以触发新的审阅!
  • 为问题生成行动计划: 在问题中评论 @sourcery-ai plan 以生成问题的行动计划。

自定义您的体验

访问您的仪表板以:

  • 启用或禁用审阅功能,如 Sourcery 生成的拉取请求摘要、审阅指南等。
  • 更改审阅语言。
  • 添加、删除或编辑自定义审阅说明。
  • 调整其他审阅设置。

获取帮助

Original review guide in English

Reviewer's Guide by Sourcery

This pull request modifies several BaseModel classes to use field(default_factory=list) or field(default_factory=dict) instead of mutable default values for list and dict attributes. This change ensures that each instance of these classes gets its own independent list or dict, preventing unintended sharing of data between instances.

Updated class diagram for Command, ConfigGroup, Task, PluginExtraData, BuildMatData, Goods, ReqResult, BotSetting, and FileInfo

classDiagram
    class Command {
        - list~str~ params
        - list~Example~ examples
    }
    class ConfigGroup {
        - dict~str, ConfigModel~ configs
    }
    class Task {
        - list check_args
    }
    class PluginExtraData {
        - list~Command~ commands
        - set~str~ aliases
    }
    class BuildMatData {
        - list~int|float~ data
        - list~str~ x_index
        - list~int|float~ y_index
        - list~str~ bar_color
    }
    class Goods {
        - list~Callable~ before_handle
        - list~Callable~ after_handle
        - dict~str, str~ kwargs
    }
    class ReqResult {
        - list~FriendRequestResult~ friend
        - list~GroupRequestResult~ group
    }
    class BotSetting {
        - dict~str, list~str~~ platform_superusers
        - dict~str, str~ qbot_id_data
    }
    class FileInfo {
        - list~FileInfo~ files
    }
    note for Command "Updated to use field(default_factory=list) for params and examples"
    note for ConfigGroup "Updated to use field(default_factory=dict) for configs"
    note for Task "Updated to use field(default_factory=list) for check_args"
    note for PluginExtraData "Updated to use field(default_factory=list) for commands and field(default_factory=set) for aliases"
    note for BuildMatData "Updated to use field(default_factory=list) for data, x_index, y_index, and bar_color"
    note for Goods "Updated to use field(default_factory=list) for before_handle and after_handle, and field(default_factory=dict) for kwargs"
    note for ReqResult "Updated to use field(default_factory=list) for friend and group"
    note for BotSetting "Updated to use field(default_factory=dict) for platform_superusers and qbot_id_data"
    note for FileInfo "Updated to use field(default_factory=list) for files"
Loading

File-Level Changes

Change Details Files
Replaced mutable default values with field(default_factory=list) for list attributes in BaseModel classes.
  • Changed params: list[str] = [] to params: list[str] = field(default_factory=list) in Command class.
  • Changed examples: list[Example] = [] to examples: list[Example] = field(default_factory=list) in Command class.
  • Changed `data: list[int
float] = []todata: list[int
Replaced mutable default values with field(default_factory=dict) for dict attributes in BaseModel classes.
  • Changed configs: dict[str, ConfigModel] = defaultdict() to configs: dict[str, ConfigModel] = field(default_factory=dict) in ConfigGroup class.
  • Changed kwargs: dict[str, str] = {} to kwargs: dict[str, str] = field(default_factory=dict) in Goods class.
  • Changed platform_superusers: dict[str, list[str]] = {} to platform_superusers: dict[str, list[str]] = field(default_factory=dict) in BotSetting class.
  • Changed qbot_id_data: dict[str, str] = {} to qbot_id_data: dict[str, str] = field(default_factory=dict) in BotSetting class.
zhenxun/configs/utils/__init__.py
zhenxun/utils/decorator/shop.py
zhenxun/configs/config.py
Replaced mutable default values with field(default_factory=set) for set attributes in BaseModel classes.
  • Changed aliases: set[str] = set() to aliases: set[str] = field(default_factory=set) in PluginExtraData class.
zhenxun/configs/utils/__init__.py
Replaced mutable default values with field(default_factory=lambda: ['*']) for list attributes with a default value in BaseModel classes.
  • Changed bar_color: list[str] = ['*'] to bar_color: list[str] = field(default_factory=lambda: ['*']) in BuildMatData class.
zhenxun/utils/_build_mat.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BalconyJH - 我已经审查了你的更改,看起来非常棒!

以下是我在审查期间查看的内容
  • 🟢 一般性问题:一切看起来都很好
  • 🟢 安全性:一切看起来都很好
  • 🟢 测试:一切看起来都很好
  • 🟢 复杂性:一切看起来都很好
  • 🟢 文档:一切看起来都很好

Sourcery 对开源项目是免费的 - 如果你喜欢我们的评论,请考虑分享 ✨
帮助我变得更有用!请在每条评论上点击 👍 或 👎,我将使用这些反馈来改进你的评论。
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: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@HibiKier HibiKier merged commit d6fd5f1 into main Jan 26, 2025
3 checks passed
@HibiKier HibiKier deleted the bugfix/mutable-default branch January 26, 2025 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants