Python验证工具

py-smart-verify是一个专业的Python验证CLI工具,集成了代码格式化、静态分析、类型检查和智能测试功能,适用于Python项目的质量保障。

  • by jinto-ag
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 jinto-ag/py_smart_verify

使用说明

py智能验证

专业的Python验证CLI工具将linting、类型检查和智能测试组合到一个命令中。

特性

  • 统一管道 -在一个命令中运行格式化程序、linter、类型检查器和测试
  • 智能测试 -仅运行受更改影响的测试(通过 py智能测试)
  • 缓存 -跳过自上次运行以来没有更改的步骤
  • 依赖图 -检测循环依赖关系并可视化模块关系
  • 代码分析 -检查架构指南、导入模式和编码标准

安装

pip install py-smart-verify

或与 紫外线:

uv add py-smart-verify

可选工具

安装所有支持的验证工具:

pip install py-smart-verify[all-tools]

快速开始

# Run all quality checks (format, lint, type check, analyze)
py-smart-verify verify quality

# Run tests (smart mode - only affected tests)
py-smart-verify verify tests

# Run everything
py-smart-verify verify

# Use the short alias
pyv verify quality

命令

verify

对Python代码运行验证检查。

# Run specific tasks
py-smart-verify verify ruff mypy

# Run with options
py-smart-verify verify --no-cache --continue quality
py-smart-verify verify --paths src,lib --full-tests
py-smart-verify verify --staged tests  # pre-commit mode

选项:

标志 描述
--no-cache 禁用缓存
--continue 出错后继续(默认:快速失败)
--paths 验证路径(逗号分隔)
--full-tests 使用智能优先级运行所有测试
--staged 仅测试阶段性更改(预提交模式)
--since REF 智能测试差异的Git参考(默认:main)
--skip-tests 跳过测试执行
-v 详细输出

graph

构建并显示依赖关系图。

py-smart-verify graph
py-smart-verify graph --output deps.json

affected

列出受代码更改影响的测试。

py-smart-verify affected
py-smart-verify affected --since main --json

regen-graph

重新生成py智能测试依赖关系图。

py-smart-verify regen-graph

可用任务

类别 任务
使用格式器 format (黑色), isort, ruff-fix
棉毛 flake8, pyflakes
类型检查器 mypy, pyright, basedpyright
分析器 architecture, standards, imports, circular-deps, deprecations
测试 tests, full-tests, e2e-tests, full-e2e-tests
复合 quality (所有格式化程序+过梁程序+类型检查器+分析器)

需求

  • Python 3.11+
  • 单独或通过以下方式安装的单个工具(ruff、mypy等) py-smart-verify[all-tools]

许可证

麻省理工学院