完成 Ruff 全量清理
This commit is contained in:
Regular → Executable
+12
-8
@@ -22,6 +22,7 @@ from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import secrets
|
||||
@@ -49,6 +50,8 @@ from pyvm.protocol import (
|
||||
)
|
||||
from pyvm.session import SessionState, load_session
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
REPLAY = ROOT / "replay"
|
||||
DEFAULT_APPID = PAY_APPID
|
||||
DEFAULT_SAVE_URL = f"https://api.unipay.qq.com/v1/r/{DEFAULT_APPID}/web_save"
|
||||
@@ -103,7 +106,8 @@ def _load_cap(path: Path) -> dict:
|
||||
d = attempt()
|
||||
if isinstance(d, dict) and "C" in d:
|
||||
return d
|
||||
except Exception:
|
||||
except Exception as exc: # noqa: BLE001
|
||||
logger.debug("deepCap 候选格式解析失败: %s", exc)
|
||||
continue
|
||||
raise ValueError(f"无法解析 deepCap 文件: {path}(前 80 字符: {raw[:80]!r})")
|
||||
|
||||
@@ -122,8 +126,8 @@ def parse_plaintext(path: str | Path) -> dict:
|
||||
d = json.loads(raw)
|
||||
if isinstance(d, dict):
|
||||
return {str(k): str(v) for k, v in d.items()}
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as exc: # noqa: BLE001
|
||||
logger.debug("订单响应 JSON 解析失败: %s", exc)
|
||||
fields: dict[str, str] = {}
|
||||
for kv in raw.split("&"):
|
||||
k, _, v = kv.partition("=")
|
||||
@@ -249,7 +253,7 @@ def cmd_submit(args) -> int:
|
||||
return 0
|
||||
print(f"❌ web_save ret:{ret}({js.get('err_code', '')})—— 见 case 踩坑记录")
|
||||
return 1
|
||||
except Exception:
|
||||
except Exception: # noqa: BLE001 外部接口与任务边界需要保留宽泛异常兜底
|
||||
return 1
|
||||
|
||||
|
||||
@@ -399,8 +403,8 @@ def cmd_mall_submit(args) -> int:
|
||||
js = json.loads(raw)
|
||||
if isinstance(js, dict):
|
||||
ret = js.get("ret", js.get("result_code", js.get("code")))
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as exc: # noqa: BLE001
|
||||
logger.debug("支付响应 JSON 解析失败: %s", exc)
|
||||
ok = ret in (0, "0")
|
||||
if ok:
|
||||
_write_private_text(out, raw)
|
||||
@@ -999,8 +1003,8 @@ def cmd_mall_pay(args) -> int:
|
||||
print("\n ══ 微信扫码支付(终端二维码)══")
|
||||
try:
|
||||
qr.terminal(compact=False)
|
||||
except Exception: # noqa: BLE001
|
||||
pass
|
||||
except Exception as exc: # noqa: BLE001
|
||||
logger.debug("终端二维码输出失败: %s", exc)
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user