Skip to content

Commit 05576ff

Browse files
committed
fix(ai-gateway): 清理基线 ruff 违规——移除未用变量/导入、import 移至顶部、修正无效 noqa 指令
1 parent 56c1bfe commit 05576ff

4 files changed

Lines changed: 3 additions & 6 deletions

File tree

‎server/ai-gateway/chains/error_pattern_chain.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ async def run(
5656
"latency_ms": 123,
5757
}
5858
"""
59-
opts = options or {}
60-
6159
# 构建输入文本
6260
errors_text = "\n".join([
6361
f"【错误 #{i+1}】\n正确答案:{e['correctAnswer']}\n用户回答:{e['userAnswer']}\n---"

‎server/ai-gateway/middleware/auth.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import base64
1616
import logging
17+
import os
1718
import time
1819
import warnings
1920
from typing import Optional
@@ -49,8 +50,7 @@ def _jwt_verification_configured() -> bool:
4950

5051
# 启动时检查密钥配置
5152
# Phase1 安全加固:生产环境缺少密钥材料时拒绝启动(而非降级放行)
52-
import os as _os
53-
_ALLOW_DEV_AUTH = _os.getenv("GATEWAY_ALLOW_DEV_AUTH", "false").lower() == "true"
53+
_ALLOW_DEV_AUTH = os.getenv("GATEWAY_ALLOW_DEV_AUTH", "false").lower() == "true"
5454

5555
if not _jwt_verification_configured():
5656
if APP_CONFIG.get("app_env") == "production" and not _ALLOW_DEV_AUTH:

‎server/ai-gateway/observability/metrics.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"""
1010

1111
import logging
12-
import time
1312
from collections import defaultdict
1413

1514
logger = logging.getLogger(__name__)

‎server/ai-gateway/tests/test_stream_fallback_timeout.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def _make_failing_stream_fn(error_msg="模拟故障"):
7070
def fn(provider, model_name):
7171
async def _gen():
7272
raise RuntimeError(error_msg)
73-
yield "unreachable" # noqa: 使 _gen 成为异步生成器
73+
yield "unreachable" # 使 _gen 成为异步生成器(此句不可达,仅为语法需要)
7474
return _gen()
7575
return fn
7676

0 commit comments

Comments
 (0)