Archived
refactor: 清理 13 处生产死代码
为什么:用 AST 级引用分析(而非文本 grep——同名符号会互相掩盖)确认这些 符号全项目零引用。文本 grep 查不出的原因是它们都有「活着的同名兄弟」: services/downloads.py(共 6 个,93 行) _parse_cookie_str / _global_music_u / _vip_name / _detect_vip / _admin_client / _user_client —— 活的是 core.media.parse_cookie_str、web/routers/music.py、account.py 的版本 随之失效的 import:USER_COOKIE_FILE / GLOBAL_MUSIC_U_CACHE / VIP_PROBE_LOCK / account_info / detect_vip_by_probe / QRLoginClient services/api_service.py APIResponse 类(29 行)—— web/response.py 才是活的响应封装 services/_shared.py _rate_ok —— 逐字复制 web.ratelimit.rate_ok core/utils.py safe_int / safe_console_print —— 活的是 web/request_utils.safe_int core/repo.py all_settings / get_user_by_name —— auth_system.get_user_by_name 才是活的 core/db.py / web/auth_state.py / web/request_utils.py execute_many / _safe_register_credits + secrets_rand / dedup_ids 结果:生产代码死代码候选 13 → 0(余下 118 个全是 pytest 测试函数,属正常)。
This commit is contained in:
1 parent
445c16c329
commit
0569b50737
8 files changed
+10
-217
No files matched your search
+1
-13
@@ -14,7 +14,7 @@
|
||||
|
||||
import asyncio
|
||||
import os
|
||||
from collections.abc import AsyncGenerator, Iterable, Sequence
|
||||
from collections.abc import AsyncGenerator, Sequence
|
||||
from contextlib import asynccontextmanager
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
@@ -126,18 +126,6 @@ async def execute(sql: str, params: Sequence = ()) -> int:
|
||||
await conn.close()
|
||||
|
||||
|
||||
async def execute_many(sql: str, seq: Iterable[Sequence]) -> int:
|
||||
"""批量写,返回受影响行数。"""
|
||||
async with _write_lock():
|
||||
conn = await connect()
|
||||
try:
|
||||
cur = await conn.executemany(sql, seq)
|
||||
await conn.commit()
|
||||
return cur.rowcount
|
||||
finally:
|
||||
await conn.close()
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def write_transaction() -> AsyncGenerator[aiosqlite.Connection, None]:
|
||||
"""写事务上下文:多条写语句原子提交(串行锁内)。
|
||||
|
||||
Reference in new issue
Block a user