ruff: 清理代码并规范导入顺序

对整个代码库进行了大规模的清理和重构,主要包括:
- 统一并修复了多个文件中的 `import` 语句顺序,使其符合 PEP 8 规范。
- 移除了大量未使用的导入和变量,减少了代码冗余。
- 修复了多处代码风格问题,例如多余的空行、不一致的引号使用等。
- 简化了异常处理逻辑,移除了不必要的 `noqa` 注释。
- 在多个文件中使用了更现代的类型注解语法(例如 `list[str]` 替代 `List[str]`)。
This commit is contained in:
minecraft1024a
2025-10-05 20:38:56 +08:00
committed by Windpicker-owo
parent 218fe58692
commit f8e62d0253
20 changed files with 163 additions and 171 deletions

View File

@@ -19,7 +19,7 @@ def get_tool_instance(tool_name: str) -> BaseTool | None:
tool_class: type[BaseTool] = component_registry.get_component_class(tool_name, ComponentType.TOOL) # type: ignore
if tool_class:
return tool_class(plugin_config)
# 如果不是常规工具检查是否是MCP工具
# MCP工具不需要返回实例会在execute_tool_call中特殊处理
return None
@@ -35,7 +35,7 @@ def get_llm_available_tool_definitions():
llm_available_tools = component_registry.get_llm_available_tools()
tool_definitions = [(name, tool_class.get_tool_definition()) for name, tool_class in llm_available_tools.items()]
# 添加MCP工具
try:
from src.plugin_system.utils.mcp_tool_provider import mcp_tool_provider
@@ -45,5 +45,5 @@ def get_llm_available_tool_definitions():
logger.debug(f"已添加 {len(mcp_tools)} 个MCP工具到可用工具列表")
except Exception as e:
logger.debug(f"获取MCP工具失败可能未配置: {e}")
return tool_definitions