fix: auto-fix code issues (cron)

- 修复隐式 Optional 类型注解 (RUF013)
- 修复不必要的赋值后返回 (RET504)
- 优化列表推导式 (PERF401)
- 修复未使用的参数 (ARG002)
- 清理重复导入
- 优化异常处理
This commit is contained in:
AutoFix Bot
2026-03-03 21:11:47 +08:00
parent d17a58ceae
commit 259f2c90d0
36 changed files with 1651 additions and 863 deletions

View File

@@ -19,7 +19,11 @@ class TingwuClient:
raise ValueError("ALI_ACCESS_KEY and ALI_SECRET_KEY required")
def _sign_request(
self, method: str, uri: str, query: str = "", body: str = "",
self,
method: str,
uri: str,
query: str = "",
body: str = "",
) -> dict[str, str]:
"""阿里云签名 V3"""
timestamp = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
@@ -43,7 +47,8 @@ class TingwuClient:
from alibabacloud_tingwu20230930.client import Client as TingwuSDKClient
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,
)
config.endpoint = "tingwu.cn-beijing.aliyuncs.com"
client = TingwuSDKClient(config)
@@ -53,7 +58,8 @@ class TingwuClient:
input=tingwu_models.Input(source="OSS", file_url=audio_url),
parameters=tingwu_models.Parameters(
transcription=tingwu_models.Transcription(
diarization_enabled=True, sentence_max_length=20,
diarization_enabled=True,
sentence_max_length=20,
),
),
)
@@ -73,7 +79,10 @@ class TingwuClient:
return f"mock_task_{int(time.time())}"
def get_task_result(
self, task_id: str, max_retries: int = 60, interval: int = 5,
self,
task_id: str,
max_retries: int = 60,
interval: int = 5,
) -> dict[str, Any]:
"""获取任务结果"""
try:
@@ -83,7 +92,8 @@ class TingwuClient:
from alibabacloud_tingwu20230930.client import Client as TingwuSDKClient
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,
)
config.endpoint = "tingwu.cn-beijing.aliyuncs.com"
client = TingwuSDKClient(config)