fix: auto-fix code issues (cron)

- 修复重复导入/字段
- 修复异常处理
- 修复PEP8格式问题
- 添加类型注解
This commit is contained in:
AutoFix Bot
2026-03-02 12:14:39 +08:00
parent e23f1fec08
commit 98527c4de4
39 changed files with 8109 additions and 8147 deletions

View File

@@ -42,7 +42,7 @@ except ImportError as e:
print("\n2. 测试模块初始化...")
try:
processor = get_multimodal_processor()
processor = get_multimodal_processor()
print(" ✓ MultimodalProcessor 初始化成功")
print(f" - 临时目录: {processor.temp_dir}")
print(f" - 帧提取间隔: {processor.frame_interval}")
@@ -50,14 +50,14 @@ except Exception as e:
print(f" ✗ MultimodalProcessor 初始化失败: {e}")
try:
img_processor = get_image_processor()
img_processor = get_image_processor()
print(" ✓ ImageProcessor 初始化成功")
print(f" - 临时目录: {img_processor.temp_dir}")
except Exception as e:
print(f" ✗ ImageProcessor 初始化失败: {e}")
try:
linker = get_multimodal_entity_linker()
linker = get_multimodal_entity_linker()
print(" ✓ MultimodalEntityLinker 初始化成功")
print(f" - 相似度阈值: {linker.similarity_threshold}")
except Exception as e:
@@ -67,20 +67,20 @@ except Exception as e:
print("\n3. 测试实体关联功能...")
try:
linker = get_multimodal_entity_linker()
linker = get_multimodal_entity_linker()
# 测试字符串相似度
sim = linker.calculate_string_similarity("Project Alpha", "Project Alpha")
sim = linker.calculate_string_similarity("Project Alpha", "Project Alpha")
assert sim == 1.0, "完全匹配应该返回1.0"
print(f" ✓ 字符串相似度计算正常 (完全匹配: {sim})")
sim = linker.calculate_string_similarity("K8s", "Kubernetes")
sim = linker.calculate_string_similarity("K8s", "Kubernetes")
print(f" ✓ 字符串相似度计算正常 (不同字符串: {sim:.2f})")
# 测试实体相似度
entity1 = {"name": "Project Alpha", "type": "PROJECT", "definition": "核心项目"}
entity2 = {"name": "Project Alpha", "type": "PROJECT", "definition": "主要项目"}
sim, match_type = linker.calculate_entity_similarity(entity1, entity2)
entity1 = {"name": "Project Alpha", "type": "PROJECT", "definition": "核心项目"}
entity2 = {"name": "Project Alpha", "type": "PROJECT", "definition": "主要项目"}
sim, match_type = linker.calculate_entity_similarity(entity1, entity2)
print(f" ✓ 实体相似度计算正常 (相似度: {sim:.2f}, 类型: {match_type})")
except Exception as e:
@@ -90,7 +90,7 @@ except Exception as e:
print("\n4. 测试图片处理器功能...")
try:
processor = get_image_processor()
processor = get_image_processor()
# 测试图片类型检测(使用模拟数据)
print(f" ✓ 支持的图片类型: {list(processor.IMAGE_TYPES.keys())}")
@@ -103,7 +103,7 @@ except Exception as e:
print("\n5. 测试视频处理器配置...")
try:
processor = get_multimodal_processor()
processor = get_multimodal_processor()
print(f" ✓ 视频目录: {processor.video_dir}")
print(f" ✓ 帧目录: {processor.frames_dir}")
@@ -129,11 +129,11 @@ print("\n6. 测试数据库多模态方法...")
try:
from db_manager import get_db_manager
db = get_db_manager()
db = get_db_manager()
# 检查多模态表是否存在
conn = db.get_conn()
tables = ["videos", "video_frames", "images", "multimodal_mentions", "multimodal_entity_links"]
conn = db.get_conn()
tables = ["videos", "video_frames", "images", "multimodal_mentions", "multimodal_entity_links"]
for table in tables:
try: