-
-
Notifications
You must be signed in to change notification settings - Fork 525
STEP 2 ⚓ pyupgrade+ruff check --fix #1335
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
base: master
Are you sure you want to change the base?
Conversation
AssistantMessageSegment 的更新类图classDiagram
class AssistantMessageSegment {
content: str
tool_calls: list[ChatCompletionMessageToolCall | dict]
role: str
to_dict()
}
ToolCallsResult 的更新类图classDiagram
class ToolCallsResult {
tool_calls_info: AssistantMessageSegment
tool_calls_result: list[ToolCallMessageSegment]
to_openai_messages() list[dict]
}
ProviderRequest 的更新类图classDiagram
class ProviderRequest {
prompt: str
session_id: str
image_urls: list[str]
func_tool: FuncCall
contexts: list
assemble_context() dict
_print_friendly_context()
}
LLMResponse 的更新类图classDiagram
class LLMResponse {
role: str
result_chain: MessageChain
tools_call_args: list[dict[str, any]]
tools_call_name: list[str]
tools_call_ids: list[str]
raw_completion: ChatCompletion
_new_record: dict[str, any]
_completion_text: str
completion_text(value)
to_openai_tool_calls() list[dict]
}
FuncCall 的更新类图classDiagram
class FuncCall {
func_list: list[FuncTool]
mcp_client_dict: dict[str, MCPClient]
mcp_client_event: dict[str, asyncio.Event]
empty() bool
register_tool(func_tool: FuncTool)
get_func_desc_anthropic_style() list
get_func_desc_google_genai_style() dict
}
Personality 的更新类图classDiagram
class Personality {
prompt: str
name: str
begin_dialogs: list[str]
mood_imitation_dialogs: list[str]
_begin_dialogs_processed: list[dict]
_mood_imitation_dialogs_processed: str
}
BaseDatabase 的更新类图classDiagram
class BaseDatabase {
update_llm_history(session_id: str, content: str, provider_type: str)
get_llm_history(session_id: str, provider_type: str) list[LLMHistory]
get_atri_vision_data() list[ATRIVision]
get_conversations(user_id: str) list[Conversation]
get_all_conversations(page: int, page_size: int) tuple[list[dict[str, Any]], int]
get_filtered_conversations(page: int, page_size: int, platforms: list[str], message_types: list[str], search_query: str, exclude_ids: list[str], exclude_platforms: list[str]) tuple[list[dict[str, Any]], int]
}
AstrMessageEvent 的更新类图classDiagram
class AstrMessageEvent {
_outline_chain(chain: list[BaseMessageComponent]) str
get_messages() list[BaseMessageComponent]
chain_result(chain: list[BaseMessageComponent]) MessageEventResult
request_llm(prompt: str, func_tool_manager, session_id: str, image_urls: list[str], contexts: list, system_prompt: str, conversation: Conversation) ProviderRequest
get_group(group_id: str, **kwargs) Group | None
}
Context 的更新类图classDiagram
class Context {
_register_tasks: list[Awaitable]
get_all_stars() list[StarMetadata]
get_all_providers() list[Provider]
get_all_tts_providers() list[TTSProvider]
get_all_stt_providers() list[STTProvider]
get_platform(platform_type: PlatformAdapterType | str) Platform
send_message(session: str | MessageSesion, message_chain: MessageChain) bool
}
MessageChain 的更新类图classDiagram
class MessageChain {
chain: list[BaseMessageComponent]
use_t2i_: bool | None
}
KnowledgeDBManager 的更新类图classDiagram
class KnowledgeDBManager {
store_insts: dict[str, Store]
list_knowledge_db() list[str]
create_knowledge_db(name: str, config: dict)
retrive_records(name: str, query: str, top_n: int) list[str]
_fixed_chunk(text: str, chunk_size: int, chunk_overlap: int) list[str]
}
CommandFilter 的更新类图classDiagram
class CommandFilter {
parent_command_names: list[str]
custom_filter_list: list[CustomFilter]
validate_and_convert_params(params: list[Any], param_type: dict[str, type]) dict[str, Any]
}
StarManager 的更新类图classDiagram
class StarManager {
_get_plugin_modules() list[dict]
}
TextMeasurer 的更新类图classDiagram
class TextMeasurer {
get_text_size(text: str, font: ImageFont.FreeTypeFont) tuple[int, int]
split_text_to_fit_width(text: str, font: ImageFont.FreeTypeFont, max_width: int) list[str]
}
CodeBlockElement 的更新类图classDiagram
class CodeBlockElement {
content: list[str]
}
registered_stages 的更新类图classDiagram
class Stage {
process(event: AstrMessageEvent) None | AsyncGenerator[None, None]
}
class registered_stages {
List[Stage]
}
ChromaVectorStore 的更新类图classDiagram
class ChromaVectorStore {
query(query: str, top_n=3, metadata_filter: dict) list[str]
}
Stats 的更新类图classDiagram
class Stats {
platform: list[Platform]
command: list[Command]
llm: list[Provider]
}
StarTools 的更新类图classDiagram
class StarTools {
send_message(session: str | MessageSesion, message_chain: MessageChain) bool
create_message(session_id: str, message_id: str, sender: MessageMember, message: list[BaseMessageComponent], message_str: str, raw_message: object, group_id: str) AstrBotMessage
get_data_dir(plugin_name: str | None) Path
}
CoreLifecycle 的更新类图classDiagram
class CoreLifecycle {
curr_tasks: list[asyncio.Task]
load_platform() list[asyncio.Task]
}
ProcessStage 的更新类图classDiagram
class ProcessStage {
process(event: AstrMessageEvent) None | AsyncGenerator[None, None]
}
RespondStage 的更新类图classDiagram
class RespondStage {
process(event: AstrMessageEvent) None | AsyncGenerator[None, None]
}
OpenAIEmbedding 的更新类图classDiagram
class OpenAIEmbedding {
get_embedding(text) list[float]
}
LogBroker 的更新类图classDiagram
class LogBroker {
subscribers: list[Queue]
}
PlatformAdapterTypeFilter 的更新类图classDiagram
class PlatformAdapterTypeFilter {
__init__(platform_adapter_type_or_str: PlatformAdapterType | str)
}
ConfigRoute 的更新类图classDiagram
class ConfigRoute {
validate_config(data, schema: dict, is_core: bool) tuple[list[str], dict]
}
SQLitePluginStorage 的更新类图classDiagram
class SQLitePluginStorage {
__new__(cls)
}
ContentSafetyStage 的更新类图classDiagram
class ContentSafetyStage {
process(event: AstrMessageEvent, check_text: str) None | AsyncGenerator[None, None]
}
ContentSafetyStrategy 的更新类图classDiagram
class ContentSafetyStrategy {
check(content: str) tuple[bool, str]
}
PlatformCompatibilityStage 的更新类图classDiagram
class PlatformCompatibilityStage {
process(event: AstrMessageEvent) None | AsyncGenerator[None, None]
}
PreprocessStage 的更新类图classDiagram
class PreprocessStage {
process(event: AstrMessageEvent) None | AsyncGenerator[None, None]
}
RateLimitCheckStage 的更新类图classDiagram
class RateLimitCheckStage {
process(event: AstrMessageEvent) None | AsyncGenerator[None, None]
}
ResultDecorateStage 的更新类图classDiagram
class ResultDecorateStage {
process(event: AstrMessageEvent) None | AsyncGenerator[None, None]
}
WakingCheckStage 的更新类图classDiagram
class WakingCheckStage {
process(event: AstrMessageEvent) None | AsyncGenerator[None, None]
}
WhitelistCheckStage 的更新类图classDiagram
class WhitelistCheckStage {
process(event: AstrMessageEvent) None | AsyncGenerator[None, None]
}
LarkEvent 的更新类图classDiagram
class LarkEvent {
_convert_to_lark(message: MessageChain, lark_client: lark.Client) list
}
文件级别变更
提示和命令与 Sourcery 互动
自定义您的体验访问您的 仪表板 以:
获取帮助Original review guide in EnglishReviewer's Guide by SourceryThis pull request applies pyupgrade and ruff to automatically modernize the codebase to be compatible with Python 3.10+. It replaces type hints like Updated class diagram for ProviderMetaDataclassDiagram
class ProviderMetaData {
desc: str
provider_type: ProviderType
cls_type: type
default_config_tmpl: dict
}
Updated class diagram for AssistantMessageSegmentclassDiagram
class AssistantMessageSegment {
content: str
tool_calls: list[ChatCompletionMessageToolCall | dict]
role: str
to_dict()
}
Updated class diagram for ToolCallsResultclassDiagram
class ToolCallsResult {
tool_calls_info: AssistantMessageSegment
tool_calls_result: list[ToolCallMessageSegment]
to_openai_messages() list[dict]
}
Updated class diagram for ProviderRequestclassDiagram
class ProviderRequest {
prompt: str
session_id: str
image_urls: list[str]
func_tool: FuncCall
contexts: list
assemble_context() dict
_print_friendly_context()
}
Updated class diagram for LLMResponseclassDiagram
class LLMResponse {
role: str
result_chain: MessageChain
tools_call_args: list[dict[str, any]]
tools_call_name: list[str]
tools_call_ids: list[str]
raw_completion: ChatCompletion
_new_record: dict[str, any]
_completion_text: str
completion_text(value)
to_openai_tool_calls() list[dict]
}
Updated class diagram for FuncCallclassDiagram
class FuncCall {
func_list: list[FuncTool]
mcp_client_dict: dict[str, MCPClient]
mcp_client_event: dict[str, asyncio.Event]
empty() bool
register_tool(func_tool: FuncTool)
get_func_desc_anthropic_style() list
get_func_desc_google_genai_style() dict
}
Updated class diagram for PersonalityclassDiagram
class Personality {
prompt: str
name: str
begin_dialogs: list[str]
mood_imitation_dialogs: list[str]
_begin_dialogs_processed: list[dict]
_mood_imitation_dialogs_processed: str
}
Updated class diagram for BaseDatabaseclassDiagram
class BaseDatabase {
update_llm_history(session_id: str, content: str, provider_type: str)
get_llm_history(session_id: str, provider_type: str) list[LLMHistory]
get_atri_vision_data() list[ATRIVision]
get_conversations(user_id: str) list[Conversation]
get_all_conversations(page: int, page_size: int) tuple[list[dict[str, Any]], int]
get_filtered_conversations(page: int, page_size: int, platforms: list[str], message_types: list[str], search_query: str, exclude_ids: list[str], exclude_platforms: list[str]) tuple[list[dict[str, Any]], int]
}
Updated class diagram for AstrMessageEventclassDiagram
class AstrMessageEvent {
_outline_chain(chain: list[BaseMessageComponent]) str
get_messages() list[BaseMessageComponent]
chain_result(chain: list[BaseMessageComponent]) MessageEventResult
request_llm(prompt: str, func_tool_manager, session_id: str, image_urls: list[str], contexts: list, system_prompt: str, conversation: Conversation) ProviderRequest
get_group(group_id: str, **kwargs) Group | None
}
Updated class diagram for ContextclassDiagram
class Context {
_register_tasks: list[Awaitable]
get_all_stars() list[StarMetadata]
get_all_providers() list[Provider]
get_all_tts_providers() list[TTSProvider]
get_all_stt_providers() list[STTProvider]
get_platform(platform_type: PlatformAdapterType | str) Platform
send_message(session: str | MessageSesion, message_chain: MessageChain) bool
}
Updated class diagram for MessageChainclassDiagram
class MessageChain {
chain: list[BaseMessageComponent]
use_t2i_: bool | None
}
Updated class diagram for KnowledgeDBManagerclassDiagram
class KnowledgeDBManager {
store_insts: dict[str, Store]
list_knowledge_db() list[str]
create_knowledge_db(name: str, config: dict)
retrive_records(name: str, query: str, top_n: int) list[str]
_fixed_chunk(text: str, chunk_size: int, chunk_overlap: int) list[str]
}
Updated class diagram for CommandFilterclassDiagram
class CommandFilter {
parent_command_names: list[str]
custom_filter_list: list[CustomFilter]
validate_and_convert_params(params: list[Any], param_type: dict[str, type]) dict[str, Any]
}
Updated class diagram for StarManagerclassDiagram
class StarManager {
_get_plugin_modules() list[dict]
}
Updated class diagram for TextMeasurerclassDiagram
class TextMeasurer {
get_text_size(text: str, font: ImageFont.FreeTypeFont) tuple[int, int]
split_text_to_fit_width(text: str, font: ImageFont.FreeTypeFont, max_width: int) list[str]
}
Updated class diagram for CodeBlockElementclassDiagram
class CodeBlockElement {
content: list[str]
}
Updated class diagram for registered_stagesclassDiagram
class Stage {
process(event: AstrMessageEvent) None | AsyncGenerator[None, None]
}
class registered_stages {
List[Stage]
}
Updated class diagram for ChromaVectorStoreclassDiagram
class ChromaVectorStore {
query(query: str, top_n=3, metadata_filter: dict) list[str]
}
Updated class diagram for StatsclassDiagram
class Stats {
platform: list[Platform]
command: list[Command]
llm: list[Provider]
}
Updated class diagram for StarToolsclassDiagram
class StarTools {
send_message(session: str | MessageSesion, message_chain: MessageChain) bool
create_message(session_id: str, message_id: str, sender: MessageMember, message: list[BaseMessageComponent], message_str: str, raw_message: object, group_id: str) AstrBotMessage
get_data_dir(plugin_name: str | None) Path
}
Updated class diagram for CoreLifecycleclassDiagram
class CoreLifecycle {
curr_tasks: list[asyncio.Task]
load_platform() list[asyncio.Task]
}
Updated class diagram for ProcessStageclassDiagram
class ProcessStage {
process(event: AstrMessageEvent) None | AsyncGenerator[None, None]
}
Updated class diagram for RespondStageclassDiagram
class RespondStage {
process(event: AstrMessageEvent) None | AsyncGenerator[None, None]
}
Updated class diagram for OpenAIEmbeddingclassDiagram
class OpenAIEmbedding {
get_embedding(text) list[float]
}
Updated class diagram for LogBrokerclassDiagram
class LogBroker {
subscribers: list[Queue]
}
Updated class diagram for PlatformAdapterTypeFilterclassDiagram
class PlatformAdapterTypeFilter {
__init__(platform_adapter_type_or_str: PlatformAdapterType | str)
}
Updated class diagram for ConfigRouteclassDiagram
class ConfigRoute {
validate_config(data, schema: dict, is_core: bool) tuple[list[str], dict]
}
Updated class diagram for SQLitePluginStorageclassDiagram
class SQLitePluginStorage {
__new__(cls)
}
Updated class diagram for ContentSafetyStageclassDiagram
class ContentSafetyStage {
process(event: AstrMessageEvent, check_text: str) None | AsyncGenerator[None, None]
}
Updated class diagram for ContentSafetyStrategyclassDiagram
class ContentSafetyStrategy {
check(content: str) tuple[bool, str]
}
Updated class diagram for PlatformCompatibilityStageclassDiagram
class PlatformCompatibilityStage {
process(event: AstrMessageEvent) None | AsyncGenerator[None, None]
}
Updated class diagram for PreprocessStageclassDiagram
class PreprocessStage {
process(event: AstrMessageEvent) None | AsyncGenerator[None, None]
}
Updated class diagram for RateLimitCheckStageclassDiagram
class RateLimitCheckStage {
process(event: AstrMessageEvent) None | AsyncGenerator[None, None]
}
Updated class diagram for ResultDecorateStageclassDiagram
class ResultDecorateStage {
process(event: AstrMessageEvent) None | AsyncGenerator[None, None]
}
Updated class diagram for WakingCheckStageclassDiagram
class WakingCheckStage {
process(event: AstrMessageEvent) None | AsyncGenerator[None, None]
}
Updated class diagram for WhitelistCheckStageclassDiagram
class WhitelistCheckStage {
process(event: AstrMessageEvent) None | AsyncGenerator[None, None]
}
Updated class diagram for LarkEventclassDiagram
class LarkEvent {
_convert_to_lark(message: MessageChain, lark_client: lark.Client) list
}
File-Level Changes
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.
嘿 @LIghtJUNction - 我已经查看了你的更改 - 这里有一些反馈:
总体评论:
- 考虑使用
TypeAlias
来表示复杂的类型提示,以提高可读性。 - 请注意,如果代码在旧版本的 Python 中使用,将
List
更改为list
以及将Dict
更改为dict
可能会产生兼容性影响。
以下是我在审查期间查看的内容
- 🟢 一般问题:一切看起来都很好
- 🟢 安全性:一切看起来都很好
- 🟢 测试:一切看起来都很好
- 🟢 复杂性:一切看起来都很好
- 🟢 文档:一切看起来都很好
帮助我变得更有用!请点击每个评论上的 👍 或 👎,我将使用反馈来改进你的评论。
Original comment in English
Hey @LIghtJUNction - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider using
TypeAlias
for complex type hints to improve readability. - Be aware that changing
List
tolist
andDict
todict
may have compatibility implications if the code is used in older Python versions.
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
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
不推荐通过新增脚本实现自动更新。更优的做法是将更新逻辑集成到 pre-commit hook 中,以确保代码提交前自动执行相关检查。 例: - repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
hooks:
- id: pyupgrade
args: [--py310-plus] |
对,这个脚本文件取消上传了 |
等合并后,我再进一步修改 |
修复了 #XYZ
Motivation
Modifications
pyupgrade + ruff check --fix
安全的修改
Check
好的,这是翻译成中文的 pull request 总结:
Sourcery 总结
使用 pyupgrade 将 Python 类型注解和代码风格升级到 Python 3.10+
增强功能:
List
和Dict
替换为list
和dict
来实现类型注解的现代化日常维护:
Original summary in English
Summary by Sourcery
Upgrade Python type annotations and code style to Python 3.10+ using pyupgrade
Enhancements:
List
andDict
withlist
anddict
Chores: