refactor: 统一类型注解风格并优化代码结构
- 将裸 except 改为显式 Exception 捕获 - 用列表推导式替换冗余 for 循环 - 为类属性添加 ClassVar 注解 - 统一 Union/Optional 写法为 | - 移除未使用的导入 - 修复 SQLAlchemy 空值比较语法 - 优化字符串拼接与字典更新逻辑 - 补充缺失的 noqa 注释与异常链 BREAKING CHANGE: 所有插件基类的类级字段现要求显式 ClassVar 注解,自定义插件需同步更新
This commit is contained in:
@@ -9,11 +9,11 @@ logger = get_logger("tool_api")
|
||||
|
||||
def get_tool_instance(tool_name: str, chat_stream: Any = None) -> BaseTool | None:
|
||||
"""获取公开工具实例
|
||||
|
||||
|
||||
Args:
|
||||
tool_name: 工具名称
|
||||
chat_stream: 聊天流对象,用于提供上下文信息
|
||||
|
||||
|
||||
Returns:
|
||||
BaseTool: 工具实例,如果工具不存在则返回None
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user