ruff归零

This commit is contained in:
明天好像没什么
2025-11-01 21:32:41 +08:00
committed by Windpicker-owo
parent f816150782
commit 3db00aa8f3
20 changed files with 121 additions and 61 deletions

View File

@@ -1,5 +1,5 @@
from abc import abstractmethod
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, ClassVar
from src.common.data_models.database_data_model import DatabaseMessages
from src.common.logger import get_logger
@@ -33,7 +33,7 @@ class BaseCommand(PlusCommand):
"""命令匹配的正则表达式"""
# 用于存储正则匹配组
matched_groups: dict[str, str] = {}
matched_groups: ClassVar[dict[str, str]] = {}
def __init__(self, message: DatabaseMessages, plugin_config: dict | None = None):
"""初始化Command组件"""

View File

@@ -14,6 +14,9 @@ from .component_registry import component_registry
logger = get_logger("plugin_manager")
# 全局背景任务集合
_background_tasks = set()
class PluginManager:
"""
@@ -142,7 +145,9 @@ class PluginManager:
logger.debug(f"为插件 '{plugin_name}' 调用 on_plugin_loaded 钩子")
try:
# 使用 asyncio.create_task 确保它不会阻塞加载流程
asyncio.create_task(plugin_instance.on_plugin_loaded())
task = asyncio.create_task(plugin_instance.on_plugin_loaded())
_background_tasks.add(task)
task.add_done_callback(_background_tasks.discard)
except Exception as e:
logger.error(f"调用插件 '{plugin_name}' 的 on_plugin_loaded 钩子时出错: {e}")