Files
live-hub-py/pyrightconfig.json
yml2213 a3c3a46b9c fix(tooling): 修复 pyright 解释器配置与类型守卫,补齐 ruff 门禁与两处历史 bug
- pyrightconfig.json 钉死 Python 3.12 虚拟环境,消除由于查找系统 Python 3.9 带来的假性报错
- 修复 huya/login.py 引用不存在函数的问题并补充单元测试
- 修复 browser_harvest.py 对 set 下标访问的错误并提升报错信息质量
- 虎牙 6 个子路由显式导入依赖,消除 import * 带来的未定义变量报警
- 规范化 Pydantic Field(default=...) 默认值声明
- 完善 solver.py / app_login.py 等核心路径类型守卫与 @overload 重载
- 在 pyproject.toml 中显式锁定 ruff lint 规则集 (E4, E7, E9, F, B, I, BLE)
- 门禁脚本同步增加 ruff check 检查并在 AGENTS.md 补齐实践经验总结
2026-10-08 12:33:39 +08:00

35 lines
1.9 KiB
JSON
Raw Permalink 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.
{
// tests/ 有意**不**做类型检查(见下方说明),所以不放进 include。
"include": ["core", "utils", "web"],
"exclude": [
"**/__pycache__",
"artifacts",
"evidence",
"scripts",
"tools",
"work"
],
"typeCheckingMode": "basic",
"reportMissingImports": "none",
"reportMissingModuleSource": "none",
// 必须显式钉死解释器:否则 pyright 会去 PATH 上摸 /usr/bin/python3(macOS 自带 3.9),
// 读到用户级 ~/Library/Python/3.9 里的 SQLAlchemy 1.4 + 把语义版本当日 3.9,
// 凭空多出约 2600 条假错(详见 pyright --verbose 的 "Assuming Python version")。
"venvPath": ".",
"venv": ".venv",
"pythonVersion": "3.12",
// ── 为什么 tests/ 不做类型检查 ───────────────────────────────────────────
// 打开 tests 会多出约 119 条,且**全部是同一类噪音**,不是测试写错了:
// 1) FastAPI 路由函数没有(也不该有)返回值注解,pyright 只能从 return
// 字面量反推成一个很窄的 dict 类型,于是 `result["items"][0]` 报
// 「No overloads for __getitem__」;给路由补注解=给 FastAPI 加了
// response_model,会真的裁剪响应体,绝不能为了消警告去加。
// 2) 测试故意传 `db=None` 走 mock 分支,而形参注解是 Session。
// 3) `resp.json()` 静态类型是 object,下标取值必然报错。
// 这三类要么得改生产签名、要么得在测试里撒 cast/ignore,属于 AGENTS.md 说的
//「没人要的重构」。测试的正确性本来就由 pytest **真跑一遍**来保证,而
// 未定义名/未用导入已由 `ruff check`(含 F 系列)覆盖。
// 要临时把 tests 也检查一遍:把 "tests" 加回上面的 include 再跑
// `./dev.sh type-check`,看完记得改回来。
}