更改部分类型注解
This commit is contained in:
committed by
Windpicker-owo
parent
a79253c714
commit
b2d91aac3d
@@ -1,3 +1,4 @@
|
||||
# Todo: 重构Action,这里现在只剩下了报错。
|
||||
import asyncio
|
||||
import time
|
||||
from abc import ABC, abstractmethod
|
||||
@@ -455,7 +456,7 @@ class BaseAction(ABC):
|
||||
|
||||
# 4. 执行Action
|
||||
logger.debug(f"{log_prefix} 开始执行...")
|
||||
execute_result = await action_instance.execute()
|
||||
execute_result = await action_instance.execute() # Todo: 修复类型错误
|
||||
# 确保返回类型符合 (bool, str) 格式
|
||||
is_success = execute_result[0] if isinstance(execute_result, tuple) and len(execute_result) > 0 else False
|
||||
message = execute_result[1] if isinstance(execute_result, tuple) and len(execute_result) > 1 else ""
|
||||
|
||||
@@ -21,10 +21,6 @@ class BasePlugin(PluginBase):
|
||||
- Command组件:处理命令请求
|
||||
- 未来可扩展:Scheduler、Listener等
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
@abstractmethod
|
||||
def get_plugin_components(
|
||||
self,
|
||||
@@ -42,7 +38,7 @@ class BasePlugin(PluginBase):
|
||||
Returns:
|
||||
List[tuple[ComponentInfo, Type]]: [(组件信息, 组件类), ...]
|
||||
"""
|
||||
raise NotImplementedError("Subclasses must implement this method")
|
||||
...
|
||||
|
||||
def register_plugin(self) -> bool:
|
||||
"""注册插件及其所有组件"""
|
||||
|
||||
@@ -27,40 +27,17 @@ class PluginBase(ABC):
|
||||
"""
|
||||
|
||||
# 插件基本信息(子类必须定义)
|
||||
@property
|
||||
@abstractmethod
|
||||
def plugin_name(self) -> str:
|
||||
return "" # 插件内部标识符(如 "hello_world_plugin")
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def enable_plugin(self) -> bool:
|
||||
return True # 是否启用插件
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def dependencies(self) -> list[str]:
|
||||
return [] # 依赖的其他插件
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def python_dependencies(self) -> list[str | PythonDependency]:
|
||||
return [] # Python包依赖,支持字符串列表或PythonDependency对象列表
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def config_file_name(self) -> str:
|
||||
return "" # 配置文件名
|
||||
plugin_name: str
|
||||
config_file_name: str
|
||||
enable_plugin: bool = True
|
||||
dependencies: list[str] = []
|
||||
python_dependencies: list[str | PythonDependency] = []
|
||||
|
||||
# manifest文件相关
|
||||
manifest_file_name: str = "_manifest.json" # manifest文件名
|
||||
manifest_data: dict[str, Any] = {} # manifest数据
|
||||
|
||||
# 配置定义
|
||||
@property
|
||||
@abstractmethod
|
||||
def config_schema(self) -> dict[str, dict[str, ConfigField] | str]:
|
||||
return {}
|
||||
config_schema: dict[str, dict[str, ConfigField] | str] = {}
|
||||
|
||||
config_section_descriptions: dict[str, str] = {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user