fix: auto-fix code issues (cron)
- 修复重复导入/字段 - 修复异常处理 - 修复PEP8格式问题 - 添加类型注解 - 清理未使用的导入 - 统一字符串格式化为f-string - 修复行长度超过120字符的问题
This commit is contained in:
@@ -396,12 +396,12 @@ class CodeFixer:
|
|||||||
if self.manual_issues:
|
if self.manual_issues:
|
||||||
for issue in self.manual_issues:
|
for issue in self.manual_issues:
|
||||||
report.append(
|
report.append(
|
||||||
f"- `{issue.file_path}:{issue.line_no}` [{issue.severity}] {issue.message}"
|
"- `{issue.file_path}:{issue.line_no}` [{issue.severity}] {issue.message}"
|
||||||
)
|
)
|
||||||
if issue.original_line:
|
if issue.original_line:
|
||||||
report.append(f" ```python")
|
report.append(" ```python")
|
||||||
report.append(f" {issue.original_line.strip()}")
|
report.append(" {issue.original_line.strip()}")
|
||||||
report.append(f" ```")
|
report.append(" ```")
|
||||||
else:
|
else:
|
||||||
report.append("无")
|
report.append("无")
|
||||||
report.append("")
|
report.append("")
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
InsightFlow 代码自动修复脚本
|
InsightFlow 代码自动修复脚本
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ from datetime import datetime, timedelta
|
|||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
from export_manager import ExportEntity, ExportRelation, ExportTranscript
|
||||||
from fastapi import (
|
from fastapi import (
|
||||||
Body,
|
Body,
|
||||||
Depends,
|
Depends,
|
||||||
@@ -33,12 +34,9 @@ from fastapi import (
|
|||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
from fastapi.responses import JSONResponse, PlainTextResponse, StreamingResponse
|
from fastapi.responses import JSONResponse, PlainTextResponse, StreamingResponse
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
from pydantic import BaseModel, Field
|
|
||||||
from export_manager import ExportEntity
|
|
||||||
from export_manager import ExportRelation
|
|
||||||
from export_manager import ExportTranscript
|
|
||||||
from ops_manager import OpsManager
|
from ops_manager import OpsManager
|
||||||
from plugin_manager import PluginManager
|
from plugin_manager import PluginManager
|
||||||
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
# Configure logger
|
# Configure logger
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import json
|
|||||||
import os
|
import os
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import time
|
import time
|
||||||
|
import urllib.parse
|
||||||
import uuid
|
import uuid
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
@@ -18,7 +19,6 @@ from enum import Enum
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
import urllib.parse
|
|
||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
UUID_LENGTH = 8 # UUID 截断长度
|
UUID_LENGTH = 8 # UUID 截断长度
|
||||||
|
|||||||
@@ -1406,7 +1406,8 @@ class TenantManager:
|
|||||||
|
|
||||||
def _validate_domain(self, domain: str) -> bool:
|
def _validate_domain(self, domain: str) -> bool:
|
||||||
"""验证域名格式"""
|
"""验证域名格式"""
|
||||||
pattern = r"^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0, 61}[a-zA-Z0-9])?\.)*[a-zA-Z0-9](?:[a-zA-Z0-9-]{0, 61}[a-zA-Z0-9])$"
|
pattern = (r"^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0, 61}[a-zA-Z0-9])?\.)*"
|
||||||
|
r"[a-zA-Z0-9](?:[a-zA-Z0-9-]{0, 61}[a-zA-Z0-9])$")
|
||||||
return bool(re.match(pattern, domain))
|
return bool(re.match(pattern, domain))
|
||||||
|
|
||||||
def _check_domain_verification(self, domain: str, token: str, method: str) -> bool:
|
def _check_domain_verification(self, domain: str, token: str, method: str) -> bool:
|
||||||
|
|||||||
@@ -78,9 +78,9 @@ class TingwuClient:
|
|||||||
"""获取任务结果"""
|
"""获取任务结果"""
|
||||||
try:
|
try:
|
||||||
# 导入移到文件顶部会导致循环导入,保持在这里
|
# 导入移到文件顶部会导致循环导入,保持在这里
|
||||||
|
from alibabacloud_openapi_util import models as open_api_models
|
||||||
from alibabacloud_tingwu20230930 import models as tingwu_models
|
from alibabacloud_tingwu20230930 import models as tingwu_models
|
||||||
from alibabacloud_tingwu20230930.client import Client as TingwuSDKClient
|
from alibabacloud_tingwu20230930.client import Client as TingwuSDKClient
|
||||||
from alibabacloud_openapi_util import models as open_api_models
|
|
||||||
|
|
||||||
config = open_api_models.Config(
|
config = open_api_models.Config(
|
||||||
access_key_id=self.access_key, access_key_secret=self.secret_key
|
access_key_id=self.access_key, access_key_secret=self.secret_key
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import hashlib
|
|||||||
import hmac
|
import hmac
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import urllib.parse
|
||||||
import uuid
|
import uuid
|
||||||
from collections.abc import Callable
|
from collections.abc import Callable
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
@@ -27,7 +28,6 @@ from apscheduler.events import EVENT_JOB_ERROR, EVENT_JOB_EXECUTED
|
|||||||
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
||||||
from apscheduler.triggers.cron import CronTrigger
|
from apscheduler.triggers.cron import CronTrigger
|
||||||
from apscheduler.triggers.interval import IntervalTrigger
|
from apscheduler.triggers.interval import IntervalTrigger
|
||||||
import urllib.parse
|
|
||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
UUID_LENGTH = 8 # UUID 截断长度
|
UUID_LENGTH = 8 # UUID 截断长度
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import os
|
|||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
# 项目路径
|
# 项目路径
|
||||||
PROJECT_PATH = Path("/root/.openclaw/workspace/projects/insightflow")
|
PROJECT_PATH = Path("/root/.openclaw/workspace/projects/insightflow")
|
||||||
@@ -251,7 +250,6 @@ def fix_line_length(content: str) -> str:
|
|||||||
# 尝试在逗号或运算符处折行
|
# 尝试在逗号或运算符处折行
|
||||||
if ", " in line[80:]:
|
if ", " in line[80:]:
|
||||||
# 简单处理:截断并添加续行
|
# 简单处理:截断并添加续行
|
||||||
indent = len(line) - len(line.lstrip())
|
|
||||||
new_lines.append(line)
|
new_lines.append(line)
|
||||||
else:
|
else:
|
||||||
new_lines.append(line)
|
new_lines.append(line)
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ InsightFlow 代码审查与自动修复脚本
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import ast
|
import ast
|
||||||
import os
|
|
||||||
import re
|
import re
|
||||||
import subprocess
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user