fix: auto-fix code issues (cron)

- 修复重复导入/字段
- 修复异常处理
- 修复PEP8格式问题 (E302, E305, E501)
- 修复行长度超过100字符的问题
- 修复F821未定义名称错误
This commit is contained in:
AutoFix Bot
2026-03-01 18:19:06 +08:00
parent 8f59c7b17c
commit e46c938b40
36 changed files with 1102 additions and 28 deletions

View File

@@ -26,6 +26,7 @@ except ImportError:
NEO4J_AVAILABLE = False
logger.warning("Neo4j driver not installed. Neo4j features will be disabled.")
@dataclass
class GraphEntity:
"""图数据库中的实体节点"""
@@ -44,6 +45,7 @@ class GraphEntity:
if self.properties is None:
self.properties = {}
@dataclass
class GraphRelation:
"""图数据库中的关系边"""
@@ -59,6 +61,7 @@ class GraphRelation:
if self.properties is None:
self.properties = {}
@dataclass
class PathResult:
"""路径查询结果"""
@@ -68,6 +71,7 @@ class PathResult:
length: int
total_weight: float = 0.0
@dataclass
class CommunityResult:
"""社区发现结果"""
@@ -77,6 +81,7 @@ class CommunityResult:
size: int
density: float = 0.0
@dataclass
class CentralityResult:
"""中心性分析结果"""
@@ -86,6 +91,7 @@ class CentralityResult:
score: float
rank: int = 0
class Neo4jManager:
"""Neo4j 图数据库管理器"""
@@ -962,9 +968,11 @@ class Neo4jManager:
return {"nodes": nodes, "relationships": relationships}
# 全局单例
_neo4j_manager = None
def get_neo4j_manager() -> Neo4jManager:
"""获取 Neo4j 管理器单例"""
global _neo4j_manager
@@ -972,6 +980,7 @@ def get_neo4j_manager() -> Neo4jManager:
_neo4j_manager = Neo4jManager()
return _neo4j_manager
def close_neo4j_manager() -> None:
"""关闭 Neo4j 连接"""
global _neo4j_manager
@@ -980,6 +989,8 @@ def close_neo4j_manager() -> None:
_neo4j_manager = None
# 便捷函数
def sync_project_to_neo4j(
project_id: str, project_name: str, entities: list[dict], relations: list[dict]
) -> None:
@@ -1033,6 +1044,7 @@ def sync_project_to_neo4j(
f"Synced project {project_id} to Neo4j: {len(entities)} entities, {len(relations)} relations"
)
if __name__ == "__main__":
# 测试代码
logging.basicConfig(level=logging.INFO)