fix: auto-fix code issues (cron)

- 修复重复导入/字段
- 修复异常处理 (BaseException -> 具体异常类型)
- 修复PEP8格式问题
- 添加类型注解
- 修复tingwu_client.py缩进错误
This commit is contained in:
OpenClaw Bot
2026-02-27 15:20:03 +08:00
parent 96f08b8bb9
commit 646b64daf7
10 changed files with 27 additions and 51 deletions

View File

@@ -124,7 +124,7 @@ class KnowledgeReasoner:
if json_match:
try:
return json.loads(json_match.group())
except BaseException:
except (json.JSONDecodeError, KeyError):
pass
return {"type": "factual", "entities": [], "intent": "general", "complexity": "simple"}
@@ -178,7 +178,7 @@ class KnowledgeReasoner:
related_entities=[],
gaps=data.get("knowledge_gaps", []),
)
except BaseException:
except (json.JSONDecodeError, KeyError):
pass
return ReasoningResult(
@@ -232,7 +232,7 @@ class KnowledgeReasoner:
related_entities=[],
gaps=data.get("knowledge_gaps", []),
)
except BaseException:
except (json.JSONDecodeError, KeyError):
pass
return ReasoningResult(
@@ -286,7 +286,7 @@ class KnowledgeReasoner:
related_entities=[],
gaps=data.get("knowledge_gaps", []),
)
except BaseException:
except (json.JSONDecodeError, KeyError):
pass
return ReasoningResult(
@@ -340,7 +340,7 @@ class KnowledgeReasoner:
related_entities=[],
gaps=data.get("knowledge_gaps", []),
)
except BaseException:
except (json.JSONDecodeError, KeyError):
pass
return ReasoningResult(
@@ -360,8 +360,6 @@ class KnowledgeReasoner:
使用 BFS 在关系图中搜索路径
"""
# 实体数据可用于调试或扩展功能
_ = {e["id"]: e for e in graph_data.get("entities", [])}
relations = graph_data.get("relations", [])
# 构建邻接表
@@ -483,7 +481,7 @@ class KnowledgeReasoner:
if json_match:
try:
return json.loads(json_match.group())
except BaseException:
except (json.JSONDecodeError, KeyError):
pass
return {