This repository has been archived on 2026-10-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
NeteaseUrl/pyproject.toml
T
snowy-yang 4962542e78 feat(core): requests 兼容异步垫片 + 同步/异步桥
- core/aiohttp_compat.py:以 requests 同形 API(post/get + Response.json/text/
  status_code/raise_for_status + HTTPError/RequestException/Timeout)实现异步请求,
  使既有 requests 风格代码可「加 await + async def」最小改动迁移;4xx/5xx 不抛、
  仅 raise_for_status() 抛(与 requests 语义一致,保住风控判断逻辑)
- core/async_bridge.py:run_sync(coro) 经常驻后台事件循环线程执行协程并阻塞等待,
  供迁移期同步调用方(遗留 Flask 路由/线程池)复用异步实现

验证:pytest 16/16;ruff All checks passed;pyright 0 errors。
2026-09-26 00:27:47 +08:00

65 lines
2.4 KiB
TOML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
[project]
name = "yunmusic-assistant"
version = "3.0.0"
description = "云村小助手 · 网易云音乐解析/下载服务(FastAPI + asyncio + aiohttp)"
requires-python = ">=3.12"
# ============ Ruff:静态检查 + 导入排序 + 格式化 ============
[tool.ruff]
target-version = "py312"
line-length = 120
extend-exclude = [".venv", ".zcode", "templates", "static", "data"]
[tool.ruff.lint]
# E/F 基础错误、I 导入排序、B bugbear、UP 升级、ASYNC 异步陷阱、S 安全、RUF
select = ["E", "F", "W", "I", "B", "UP", "C4", "ASYNC", "S", "RUF"]
ignore = [
"E501", # 行宽交给 formatter,不强制
"E402", # main.py 存在「先定义后 import」的历史结构,迁移期暂放行
"S101", # 生产代码外的 assert(测试/断言脚本)
"S104", # 绑定 0.0.0.0(服务端有意为之)
"S110", # try/except/pass(本项目大量「失败静默降级」策略,见交接文档)
"S112", # try/except/continue
"S324", # hashlib.md5 用于非安全场景(上游签名口径)
"S603", "S607", # subprocess(打包/运维脚本)
"UP009", # 保留 `# -*- coding: utf-8 -*-` 文件头(全项目既有约定)
"RUF001", "RUF002", "RUF003", # 全角字符(中文注释/文案,误报)
]
[tool.ruff.lint.per-file-ignores]
"tests/**" = ["S", "ASYNC"]
".zcode/**" = ["S", "ASYNC", "F"]
"_mkpkg.py" = ["S"]
# ASYNC109:timeout 参数是有意 API——直接转发给 aiohttp 的 ClientTimeout,
# 不是「用 sleep 当超时」的反模式。
"core/http_client.py" = ["ASYNC109"]
"core/aiohttp_compat.py" = ["ASYNC109"]
[tool.ruff.lint.isort]
known-first-party = ["core", "web", "music_api", "auth_system"]
[tool.ruff.format]
quote-style = "preserve"
# ============ Pyright:类型检查 ============
[tool.pyright]
include = ["core", "web"]
exclude = [".venv", ".zcode", "data", "downloads", "templates", "static"]
venvPath = "."
venv = ".venv"
pythonVersion = "3.12"
typeCheckingMode = "basic"
# 迁移期口径:存量 Flask 巨石(main.py/auth_*.py)暂不纳入严格检查,
# 新写的 core/ 与 web/ 要求类型干净。随迁移推进逐步把模块移入 include。
reportMissingImports = true
reportOptionalMemberAccess = "warning"
reportAttributeAccessIssue = "warning"
reportGeneralTypeIssues = "warning"
# ============ Pytest ============
[tool.pytest.ini_options]
asyncio_mode = "auto"
testpaths = ["tests"]
addopts = "-q"