Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 1, 2025

Finding and fixing incorrect type annotations

Systematically fixed all incorrect type annotations throughout the AstrBot codebase, changing the incorrect pattern Type = None to the correct Type | None = None syntax following Python 3.10+ best practices.

Changes Made

Fixed 19 files with incorrect type annotations across multiple modules:

CLI and Utilities:

  • astrbot/cli/commands/cmd_conf.py - Fixed key parameter type annotation
  • astrbot/cli/commands/cmd_init.py - Added Path type annotation for astrbot_root parameter
  • astrbot/cli/utils/plugin.py - Fixed backup_path None checks

Core Utilities:

  • astrbot/core/utils/pip_installer.py - Fixed installer parameters
  • astrbot/core/utils/io.py - Fixed download_image_by_url parameters

Platform Adapters:

  • astrbot/core/platform/platform_metadata.py - Fixed dataclass fields
  • astrbot/core/platform/register.py - Fixed register_platform_adapter parameters
  • astrbot/core/platform/astr_message_event.py - Fixed request_llm and get_group parameters
  • astrbot/core/platform/astrbot_message.py - Fixed MessageMember and Group dataclasses

Platform Sources:

  • astrbot/core/platform/sources/discord/components.py - Fixed DiscordEmbed and DiscordButton parameters
  • astrbot/core/platform/sources/discord/client.py - Fixed proxy parameter
  • astrbot/core/platform/sources/discord/discord_platform_adapter.py - Fixed params parameter
  • astrbot/core/platform/sources/qqofficial/qqofficial_message_event.py - Fixed message parameters
  • astrbot/core/platform/sources/wechatpadpro/xml_data_parser.py - Fixed raw_message parameter
  • astrbot/core/platform/sources/aiocqhttp/aiocqhttp_message_event.py - Fixed session_id parameter

Provider and Configuration:

  • astrbot/core/provider/provider.py - Fixed text_chat and text_chat_stream abstract methods
  • astrbot/core/provider/register.py - Fixed register_provider_adapter parameters
  • astrbot/core/config/astrbot_config.py - Fixed schema and replace_config parameters

Dashboard:

  • astrbot/dashboard/routes/config.py - Fixed conf_id parameter

Merge Conflict Resolution

Successfully resolved all merge conflicts with the dev branch:

  • Branch rebased onto latest dev to incorporate upstream changes
  • Files deleted in dev (message_session.py, sqlite_v3.py, persona_mgr.py, platform_message_history_mgr.py) were properly removed
  • astrbot/cli/utils/version_comparator.py - Kept dev branch version which already contained the type annotation fixes
  • All other type annotation fixes preserved and applied correctly

Validation

  • ✅ All merge conflicts resolved successfully
  • ✅ Branch rebased on latest dev branch
  • ✅ Code properly formatted with ruff format
  • ✅ Verified all Type = None patterns fixed throughout the codebase
  • ✅ Type checking improved with pyright

The changes are focused and consistent, correcting type annotations without altering any functionality.

Original prompt

寻找错误的类型标注,并修正(可以使用ruff工具查找)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@LIghtJUNction LIghtJUNction marked this pull request as ready for review November 1, 2025 18:55
@LIghtJUNction LIghtJUNction requested a review from Copilot November 1, 2025 18:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request.

@LIghtJUNction LIghtJUNction marked this pull request as draft November 1, 2025 19:01
Copilot AI and others added 2 commits November 1, 2025 19:04
Co-authored-by: LIghtJUNction <106986785+LIghtJUNction@users.noreply.github.com>
Co-authored-by: LIghtJUNction <106986785+LIghtJUNction@users.noreply.github.com>
@LIghtJUNction
Copy link
Member

@copilot 继续

Copilot AI and others added 2 commits November 2, 2025 06:07
Co-authored-by: LIghtJUNction <106986785+LIghtJUNction@users.noreply.github.com>
Co-authored-by: LIghtJUNction <106986785+LIghtJUNction@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 2, 2025

@copilot 继续

已完成所有类型标注错误的修复!

修复内容:

  • 修复了所有 Type = None 模式的类型标注,改为正确的 Type | None = None
  • 共修复了 24 个文件中的类型标注错误
  • 所有更改已通过 ruff check 和 ruff format 验证

最新提交: 5a29b04

Copilot AI changed the title [WIP] Fix incorrect type annotations and errors Fix incorrect type annotations and errors Nov 2, 2025
Copilot AI requested a review from LIghtJUNction November 2, 2025 06:10
Copilot finished work on behalf of LIghtJUNction November 2, 2025 06:10
@LIghtJUNction
Copy link
Member

@copilot 解决冲突

Copy link
Contributor Author

Copilot AI commented Nov 2, 2025

@copilot 解决冲突

已成功解决所有合并冲突!

冲突解决详情:

  • 移除了在 dev 分支中已删除的文件: message_session.py, sqlite_v3.py, persona_mgr.py, platform_message_history_mgr.py
  • version_comparator.py 保留了 dev 分支的版本(已经包含类型标注修复)
  • 其他所有文件应用了我们的类型标注修复

合并后状态:

  • ✅ 分支已基于最新的 dev 分支
  • ✅ 所有类型标注错误已修复
  • ✅ Ruff 检查通过(仅 3 个无关的预存在错误)

最新提交: edf8e00

Copilot finished work on behalf of LIghtJUNction November 2, 2025 06:54
@LIghtJUNction
Copy link
Member

检查完毕,安全

@LIghtJUNction LIghtJUNction merged commit 94bf3b8 into master Nov 2, 2025
@LIghtJUNction LIghtJUNction marked this pull request as ready for review November 2, 2025 09:34
@auto-assign auto-assign bot requested a review from Fridemn November 2, 2025 09:34
@auto-assign auto-assign bot requested a review from Raven95676 November 2, 2025 09:34
@LIghtJUNction LIghtJUNction deleted the copilot/fix-type-annotations-errors branch November 4, 2025 12:29
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