完成 Ruff 全量清理

This commit is contained in:
yml2213
2026-08-31 10:55:44 +08:00
parent 840af3108e
commit 09ab80e062
68 changed files with 323 additions and 291 deletions
+2 -2
View File
@@ -483,7 +483,7 @@ def _check_cookies(ids: str, db: Session, current: User, *, detailed: bool) -> d
for future in as_completed(futures):
try:
results.append(future.result())
except Exception as exc:
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
task = futures[future]
results.append(
{
@@ -623,7 +623,7 @@ def _start_relogin_tasks(
def run_relogin_batch():
try:
runner.run()
except Exception as exc:
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
runner._push_log("error", f"批量重新登录异常: {exc}")
message = f"重新登录异常: {exc}(旧 Cookie 已保留)"
for task_id in task_ids:
+5 -3
View File
@@ -852,12 +852,14 @@ def stop_auto_register_batch(
)
def retry_auto_register_batch(
batch_id: str,
req: HuyaAutoRegisterRetryRequest = HuyaAutoRegisterRetryRequest.model_construct(),
req: HuyaAutoRegisterRetryRequest | None = None,
db: Session = Depends(get_db),
current: User = Depends(get_current_user),
):
"""继续批次:默认从停止处往下跑(跳过成功与已失败);可传 mode 改行为。"""
_require_huya_perm(current, "huya:import")
if req is None:
req = HuyaAutoRegisterRetryRequest.model_construct()
use_proxy = req.use_proxy
# 先看历史批次是否用过代理
snapshot = huya_register_registry.get_snapshot(batch_id)
@@ -1075,7 +1077,7 @@ def password_login_selected_accounts(
"account": _account_out(account, include_cookie=include_cookie),
}
)
except Exception as exc:
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
account.status = "login_failed"
account.updated_at = datetime.now(UTC)
db.commit()
@@ -1239,7 +1241,7 @@ def app_password_login_selected_accounts(
"account": _account_out(account, include_cookie=include_cookie),
}
)
except Exception as exc:
except Exception as exc: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
account.status = "login_failed"
account.updated_at = datetime.now(UTC)
db.commit()
+5 -3
View File
@@ -58,9 +58,11 @@ async def create_batch(
acc = db.query(Account).filter(Account.id == aid).first()
if not acc:
continue
if not user_has_permission(current, "login:view_all"):
if acc.assigned_to != current.id:
continue
if (
not user_has_permission(current, "login:view_all")
and acc.assigned_to != current.id
):
continue
valid_ids.append(aid)
if not valid_ids: