fix: auto-fix code issues (cron)
- 修复重复导入/字段 - 修复异常处理 - 修复PEP8格式问题 - 添加类型注解 - 清理未使用的导入 - 统一字符串格式化为f-string - 修复行长度超过120字符的问题
This commit is contained in:
@@ -18,6 +18,7 @@ from datetime import datetime, timedelta
|
||||
from typing import Any, Optional
|
||||
|
||||
import httpx
|
||||
from export_manager import ExportEntity, ExportRelation, ExportTranscript
|
||||
from fastapi import (
|
||||
Body,
|
||||
Depends,
|
||||
@@ -33,12 +34,9 @@ from fastapi import (
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import JSONResponse, PlainTextResponse, StreamingResponse
|
||||
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 plugin_manager import PluginManager
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
# Configure logger
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -1166,7 +1164,7 @@ async def create_manual_entity(
|
||||
start_pos=entity.start_pos,
|
||||
end_pos=entity.end_pos,
|
||||
text_snippet=text[
|
||||
max(0, entity.start_pos - 20) : min(len(text), entity.end_pos + 20)
|
||||
max(0, entity.start_pos - 20): min(len(text), entity.end_pos + 20)
|
||||
],
|
||||
confidence=1.0,
|
||||
)
|
||||
@@ -1408,7 +1406,7 @@ async def upload_audio(project_id: str, file: UploadFile = File(...), _=Depends(
|
||||
start_pos=pos,
|
||||
end_pos=pos + len(name),
|
||||
text_snippet=full_text[
|
||||
max(0, pos - 20) : min(len(full_text), pos + len(name) + 20)
|
||||
max(0, pos - 20): min(len(full_text), pos + len(name) + 20)
|
||||
],
|
||||
confidence=1.0,
|
||||
)
|
||||
@@ -1534,7 +1532,7 @@ async def upload_document(project_id: str, file: UploadFile = File(...), _=Depen
|
||||
start_pos=pos,
|
||||
end_pos=pos + len(name),
|
||||
text_snippet=full_text[
|
||||
max(0, pos - 20) : min(len(full_text), pos + len(name) + 20)
|
||||
max(0, pos - 20): min(len(full_text), pos + len(name) + 20)
|
||||
],
|
||||
confidence=1.0,
|
||||
)
|
||||
|
||||
@@ -11,6 +11,7 @@ import json
|
||||
import os
|
||||
import sqlite3
|
||||
import time
|
||||
import urllib.parse
|
||||
import uuid
|
||||
from dataclasses import dataclass, field
|
||||
from datetime import datetime
|
||||
@@ -18,7 +19,6 @@ from enum import Enum
|
||||
from typing import Any
|
||||
|
||||
import httpx
|
||||
import urllib.parse
|
||||
|
||||
# Constants
|
||||
UUID_LENGTH = 8 # UUID 截断长度
|
||||
|
||||
@@ -385,7 +385,7 @@ class FullTextSearch:
|
||||
# 排序和分页
|
||||
scored_results.sort(key=lambda x: x.score, reverse=True)
|
||||
|
||||
return scored_results[offset : offset + limit]
|
||||
return scored_results[offset: offset + limit]
|
||||
|
||||
def _parse_boolean_query(self, query: str) -> dict:
|
||||
"""
|
||||
|
||||
@@ -1406,7 +1406,8 @@ class TenantManager:
|
||||
|
||||
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))
|
||||
|
||||
def _check_domain_verification(self, domain: str, token: str, method: str) -> bool:
|
||||
|
||||
@@ -78,9 +78,9 @@ class TingwuClient:
|
||||
"""获取任务结果"""
|
||||
try:
|
||||
# 导入移到文件顶部会导致循环导入,保持在这里
|
||||
from alibabacloud_openapi_util import models as open_api_models
|
||||
from alibabacloud_tingwu20230930 import models as tingwu_models
|
||||
from alibabacloud_tingwu20230930.client import Client as TingwuSDKClient
|
||||
from alibabacloud_openapi_util import models as open_api_models
|
||||
|
||||
config = open_api_models.Config(
|
||||
access_key_id=self.access_key, access_key_secret=self.secret_key
|
||||
|
||||
@@ -15,6 +15,7 @@ import hashlib
|
||||
import hmac
|
||||
import json
|
||||
import logging
|
||||
import urllib.parse
|
||||
import uuid
|
||||
from collections.abc import Callable
|
||||
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.triggers.cron import CronTrigger
|
||||
from apscheduler.triggers.interval import IntervalTrigger
|
||||
import urllib.parse
|
||||
|
||||
# Constants
|
||||
UUID_LENGTH = 8 # UUID 截断长度
|
||||
|
||||
Reference in New Issue
Block a user