完成 Ruff 全量清理
This commit is contained in:
@@ -22,6 +22,8 @@ import random
|
||||
from collections.abc import Mapping
|
||||
from pathlib import Path
|
||||
|
||||
from loguru import logger
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent.parent
|
||||
DATA_DIR = ROOT / "data"
|
||||
PRIMARY_PROFILE_DB = DATA_DIR / "huya_device_profiles.json"
|
||||
@@ -119,13 +121,13 @@ def _load_db() -> dict:
|
||||
if PRIMARY_PROFILE_DB.exists():
|
||||
try:
|
||||
return json.loads(PRIMARY_PROFILE_DB.read_text("utf-8"))
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as exc: # noqa: BLE001
|
||||
logger.debug(f"读取主设备画像库失败: {exc}")
|
||||
if FALLBACK_PROFILE_DB.exists():
|
||||
try:
|
||||
return json.loads(FALLBACK_PROFILE_DB.read_text("utf-8"))
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as exc: # noqa: BLE001
|
||||
logger.debug(f"读取备用设备画像库失败: {exc}")
|
||||
return {}
|
||||
|
||||
|
||||
@@ -135,8 +137,8 @@ def _save_db(db: dict) -> None:
|
||||
PRIMARY_PROFILE_DB.write_text(
|
||||
json.dumps(db, indent=2, ensure_ascii=False), encoding="utf-8"
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as exc: # noqa: BLE001
|
||||
logger.debug(f"保存设备画像库失败: {exc}")
|
||||
|
||||
|
||||
def _enrich_profile(profile: dict) -> tuple[dict, bool]:
|
||||
|
||||
Reference in New Issue
Block a user