fix: 清理22个F841 unused-variable,解除CI Validate-Style阻塞
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 1s
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 30s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 29s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 1m6s
CI/CD Pipeline / Unit Tests (pull_request) Failing after 1m8s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m30s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 1m50s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m1s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 2m59s
AI Code Review / AI Code Review (pull_request) Successful in 6m20s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 7m23s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Failing after 3s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 4m33s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 41s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 37s

全部为 except Exception as e: 中变量e未使用的模式,
ruff自动修复将 e: 改为 :。不涉及任何业务逻辑变更。
This commit is contained in:
xiaoxia
2026-09-10 17:39:08 +08:00
parent 129e5a957d
commit ff833ce7e0
7 changed files with 22 additions and 22 deletions
+1 -1
View File
@@ -336,7 +336,7 @@ def get_project_asset_diagnosis(
assets.extend(asset_repository.list_by_library(library.id))
except HTTPException:
raise
except Exception as e:
except Exception:
logger.exception("素材诊断查询失败: project_id=%s", project_id)
# 返回空诊断结果,避免 500
return _build_diagnosis(project_id, [])
+1 -1
View File
@@ -177,7 +177,7 @@ def _cleanup_expired_uploads() -> int:
meta_file.unlink()
cleaned += 1
logger.info(f"Cleaned up expired upload: {upload_id}")
except Exception as e:
except Exception:
logger.exception("Failed to cleanup upload metadata: %s", meta_file)
return cleaned
@@ -107,7 +107,7 @@ def create_variant_plans(
)
if _latest:
source_plan_id = _latest.id
except Exception as e:
except Exception:
logger.exception("[variant-plans] 源 plan 解析失败")
if not source_plan_id:
@@ -121,7 +121,7 @@ def create_variant_plans(
from app.api.routes.generation_tasks import _query_voice_durations
voice_durations = _query_voice_durations(db, voices)
except Exception as e:
except Exception:
logger.exception("[variant-plans] 配音时长查询失败(按占位段长选片)")
voice_durations = [0.0] * request.count
@@ -65,7 +65,7 @@ def _build_asset_analyses(
if url:
video_urls.append(url)
valid_asset_ids.append(aid)
except Exception as e:
except Exception:
logger.exception("获取素材URL失败: asset_id=%s", aid)
if not video_urls:
@@ -176,7 +176,7 @@ def editor_ai_recommend(
)
try:
db.rollback()
except Exception as e:
except Exception:
logger.exception("db rollback failed in ai_recommend")
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
@@ -140,7 +140,7 @@ def _build_asset_url_map(
try:
assets = asset_repo.find_by_ids(unique_ids)
asset_map = {a.id: a for a in assets}
except Exception as e:
except Exception:
logger.exception("批量查询素材失败: asset_ids=%s", asset_ids)
return {aid: None for aid in asset_ids if aid}
@@ -155,7 +155,7 @@ def _build_asset_url_map(
result[aid] = None
continue
result[aid] = storage.get_download_url(storage_key, expires_seconds=3600)
except Exception as e:
except Exception:
logger.exception("生成素材签名URL失败: asset_id=%s", aid)
result[aid] = None
@@ -486,7 +486,7 @@ def _get_mediakit_recommendations(
if url:
video_urls.append(url)
valid_asset_ids.append(asset_id)
except Exception as e:
except Exception:
logger.exception("获取素材URL失败: asset_id=%s", asset_id)
if not video_urls:
@@ -987,7 +987,7 @@ def _update_mediakit_recommendations_async( # pragma: no cover
if storage_key and mime.startswith("video/"):
try:
video_url = storage.get_download_url(storage_key)
except Exception as e:
except Exception:
logger.exception("后台任务: 获取素材URL失败: asset_id=%s", asset_id)
# 构建该素材的占用区间列表(排除已更新片段)
@@ -1039,7 +1039,7 @@ def _update_mediakit_recommendations_async( # pragma: no cover
asset_id,
len(scene_changes),
)
except Exception as cache_err:
except Exception:
# 缓存写入失败不影响本次片段更新
logger.exception(
"后台任务: 场景点缓存写入失败: asset_id=%s",
@@ -1123,7 +1123,7 @@ def _update_mediakit_recommendations_async( # pragma: no cover
recommended_start + clip_duration,
plan_id,
)
except Exception as me:
except Exception:
logger.exception(
"后台任务: 同步素材区间记录失败,回滚本次片段更新: clip_id=%s",
clip.id,
@@ -1142,27 +1142,27 @@ def _update_mediakit_recommendations_async( # pragma: no cover
asset_id,
recommended_start,
)
except Exception as ue:
except Exception:
logger.exception("后台任务: 单个片段更新失败: clip_id=%s", clip.id)
try:
db.rollback()
except Exception as e:
except Exception:
pass
continue
logger.info("后台任务完成: plan_id=%s 成功更新 %d 个片段", plan_id, updated_count)
except Exception as e:
except Exception:
# 后台任务失败不影响已创建的片段,静默处理
logger.exception("后台任务异常: plan_id=%s", plan_id)
if db:
try:
db.rollback()
except Exception as e:
except Exception:
pass
finally:
if db:
try:
db.close()
except Exception as e:
except Exception:
pass
+2 -2
View File
@@ -167,7 +167,7 @@ def create_voice_clone(
# P2-3: Celery 调度失败时标记 profile 为 failed,避免永久卡在 processing
try:
workflow.process_clone_failure(profile.id, f"Celery 任务调度失败: {e}")
except Exception as inner_e:
except Exception:
logger.exception("Failed to mark profile as failed after dispatch error")
return _to_response(profile)
@@ -281,7 +281,7 @@ def retry_voice_clone(
# P2-3: Celery 调度失败时标记 profile 为 failed,避免永久卡在 processing
try:
workflow.process_clone_failure(profile.id, f"Celery 任务调度失败: {e}")
except Exception as inner_e:
except Exception:
logger.exception("Failed to mark profile as failed after dispatch error")
return _to_response(profile)
+3 -3
View File
@@ -105,7 +105,7 @@ def _resolve_preset_preview_url(
_preset_preview_cache[voice_id] = (audio_url, time.time())
logger.info("Preset voice preview generated: %s", voice_id)
return audio_url
except Exception as e:
except Exception:
logger.exception("Failed to generate preset voice preview: voice_id=%s", voice_id)
return fallback_url
@@ -126,7 +126,7 @@ def _resolve_all_preset_preview_urls(
for p in presets:
try:
result_map[p.voice_id] = _resolve_preset_preview_url(p.voice_id, p.preview_url, cosyvoice)
except Exception as e:
except Exception:
logger.exception("Failed to resolve preset preview URL: voice_id=%s", p.voice_id)
result_map[p.voice_id] = p.preview_url
return result_map
@@ -732,7 +732,7 @@ def _find_or_create_voice_library_for_extract(*, user_id, project_repository, as
if session is not None:
try:
session.rollback()
except Exception as e:
except Exception:
logger.exception("session rollback failed in _find_or_create_voice_library")
for lib in asset_library_repository.find_by_project(project.id):
kind = lib.kind.value if hasattr(lib.kind, "value") else lib.kind