chore: 引入 pyright 类型检查清零 + README 工程化章节
pyright(basic 模式)从 15 errors / 10 warnings 降到 0/0: - pyproject: pythonPlatform="All"(termios/msvcrt 双平台分支不再误报), reportUnsupportedDunderAll=false(__init__ 惰性导出属正常写法) - keys.py: 捕获 sys.stdin 局部变量 + 提前返回,消除 fileno() 的 None 收窄告警 - server/app.py: lifespan 改用 @asynccontextmanager 并标注 AsyncIterator[None] - server/actions.py: 显式标注 result: dict[str, Any],消除 isinstance 冗余报错 - server/__main__.py: 用 importlib.util.find_spec 探测 websockets - tests/test_server.py: 同上,uvicorn 探测改为 find_spec - tools/preview_tui.py: TYPE_CHECKING 下引入 RemoteFarm,修正返回类型标注 - farm/tui.py: 取消未使用变量,统一 round/取整写法 其他: - README: 新增第 11 节「工程化:uv + ruff + pyright」,快速开始全部改用 uv sync / uv run;原第 11 节起顺延为 12 - requirements.txt: 由 uv export --no-dev --no-hashes 重新生成(锁定版本) - 清理临时日志文件 验收:ruff check 全通过 / ruff format 26 文件无改动 / pyright 0 错误 / unittest 97 项全部通过
This commit is contained in:
1 parent
fcd4cb4649
commit
d7a7107b0a
11 files changed
+200
-74
No files matched your search
@@ -112,7 +112,13 @@ line-ending = "auto" # Windows/Linux 混用时不要强改行尾,避免
|
||||
include = ["farm", "tests", "tools", "main.py", "ai_player.py"]
|
||||
exclude = [".venv", "**/__pycache__", ".ruff_cache", "saves", "run", "tests/_tmp"]
|
||||
pythonVersion = "3.10"
|
||||
# 代码里有 termios / msvcrt 这类平台专属分支。只按当前平台分析,
|
||||
# 会把另一侧的调用误报成"模块没有这个属性",所以让 pyright 同时考虑所有平台。
|
||||
pythonPlatform = "All"
|
||||
typeCheckingMode = "basic"
|
||||
reportMissingTypeStubs = false # 让"没装 third-party 存根"保持安静
|
||||
reportUnusedImport = true
|
||||
reportUnnecessaryIsInstance = true
|
||||
# __all__ 里写子模块名是 `farm/__init__.py` 惰性导出的正常写法,
|
||||
# pyright 只认模块里真实存在的名字,这条对我们是纯噪音
|
||||
reportUnsupportedDunderAll = false
|
||||
Reference in new issue
Block a user