refactor: 统一类型注解风格并优化代码结构

- 将裸 except 改为显式 Exception 捕获
- 用列表推导式替换冗余 for 循环
- 为类属性添加 ClassVar 注解
- 统一 Union/Optional 写法为 |
- 移除未使用的导入
- 修复 SQLAlchemy 空值比较语法
- 优化字符串拼接与字典更新逻辑
- 补充缺失的 noqa 注释与异常链

BREAKING CHANGE: 所有插件基类的类级字段现要求显式 ClassVar 注解,自定义插件需同步更新
This commit is contained in:
明天好像没什么
2025-10-31 22:42:39 +08:00
parent 5080cfccfc
commit 0e129d385e
105 changed files with 592 additions and 561 deletions

View File

@@ -306,10 +306,8 @@ class EmbeddingStore:
def save_to_file(self) -> None:
"""保存到文件"""
data = []
logger.info(f"正在保存{self.namespace}嵌入库到文件{self.embedding_file_path}")
for item in self.store.values():
data.append(item.to_dict())
data = [item.to_dict() for item in self.store.values()]
data_frame = pd.DataFrame(data)
if not os.path.exists(self.dir):

View File

@@ -15,15 +15,14 @@ def dyn_select_top_k(
# 归一化
max_score = sorted_score[0][1]
min_score = sorted_score[-1][1]
normalized_score = []
for score_item in sorted_score:
normalized_score.append(
(
score_item[0],
score_item[1],
(score_item[1] - min_score) / (max_score - min_score),
)
normalized_score = [
(
score_item[0],
score_item[1],
(score_item[1] - min_score) / (max_score - min_score),
)
for score_item in sorted_score
]
# 寻找跳变点score变化最大的位置
jump_idx = 0