fix: auto-fix code issues (cron)
- 修复隐式 Optional 类型注解 (RUF013) - 修复不必要的赋值后返回 (RET504) - 优化列表推导式 (PERF401) - 修复未使用的参数 (ARG002) - 清理重复导入 - 优化异常处理
This commit is contained in:
@@ -75,7 +75,10 @@ class ExportManager:
|
||||
self.db = db_manager
|
||||
|
||||
def export_knowledge_graph_svg(
|
||||
self, project_id: str, entities: list[ExportEntity], relations: list[ExportRelation],
|
||||
self,
|
||||
project_id: str,
|
||||
entities: list[ExportEntity],
|
||||
relations: list[ExportRelation],
|
||||
) -> str:
|
||||
"""
|
||||
导出知识图谱为 SVG 格式
|
||||
@@ -220,7 +223,10 @@ class ExportManager:
|
||||
return "\n".join(svg_parts)
|
||||
|
||||
def export_knowledge_graph_png(
|
||||
self, project_id: str, entities: list[ExportEntity], relations: list[ExportRelation],
|
||||
self,
|
||||
project_id: str,
|
||||
entities: list[ExportEntity],
|
||||
relations: list[ExportRelation],
|
||||
) -> bytes:
|
||||
"""
|
||||
导出知识图谱为 PNG 格式
|
||||
@@ -337,7 +343,9 @@ class ExportManager:
|
||||
return output.getvalue()
|
||||
|
||||
def export_transcript_markdown(
|
||||
self, transcript: ExportTranscript, entities_map: dict[str, ExportEntity],
|
||||
self,
|
||||
transcript: ExportTranscript,
|
||||
entities_map: dict[str, ExportEntity],
|
||||
) -> str:
|
||||
"""
|
||||
导出转录文本为 Markdown 格式
|
||||
@@ -417,7 +425,12 @@ class ExportManager:
|
||||
|
||||
output = io.BytesIO()
|
||||
doc = SimpleDocTemplate(
|
||||
output, pagesize=A4, rightMargin=72, leftMargin=72, topMargin=72, bottomMargin=18,
|
||||
output,
|
||||
pagesize=A4,
|
||||
rightMargin=72,
|
||||
leftMargin=72,
|
||||
topMargin=72,
|
||||
bottomMargin=18,
|
||||
)
|
||||
|
||||
# 样式
|
||||
@@ -510,7 +523,8 @@ class ExportManager:
|
||||
)
|
||||
|
||||
entity_table = Table(
|
||||
entity_data, colWidths=[1.5 * inch, 1 * inch, 1 * inch, 2.5 * inch],
|
||||
entity_data,
|
||||
colWidths=[1.5 * inch, 1 * inch, 1 * inch, 2.5 * inch],
|
||||
)
|
||||
entity_table.setStyle(
|
||||
TableStyle(
|
||||
@@ -539,7 +553,8 @@ class ExportManager:
|
||||
relation_data.append([r.source, r.relation_type, r.target, f"{r.confidence:.2f}"])
|
||||
|
||||
relation_table = Table(
|
||||
relation_data, colWidths=[2 * inch, 1.5 * inch, 2 * inch, 1 * inch],
|
||||
relation_data,
|
||||
colWidths=[2 * inch, 1.5 * inch, 2 * inch, 1 * inch],
|
||||
)
|
||||
relation_table.setStyle(
|
||||
TableStyle(
|
||||
|
||||
Reference in New Issue
Block a user