From python-skills
评估 Python 代码是否符合本仓库制定的质量标准,涵盖代码风格、类型注解、测试覆盖、 可读性和性能。在提交代码前或审查他人代码时使用此 skill。
npx claudepluginhub zengbin93/python_coding_skills --plugin python-skillsThis skill uses the workspace's default tool permissions.
对照本仓库制定的以下标准评估代码质量:
Guides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Migrates code, prompts, and API calls from Claude Sonnet 4.0/4.5 or Opus 4.1 to Opus 4.5, updating model strings on Anthropic, AWS, GCP, Azure platforms.
Analyzes BMad project state from catalog CSV, configs, artifacts, and query to recommend next skills or answer questions. Useful for help requests, 'what next', or starting BMad.
对照本仓库制定的以下标准评估代码质量:
类型注解
X | None 而非 Optional[X]list[X]、dict[K, V])而非 typing.List、typing.Dictfrom __future__ import annotations(视项目配置)命名规范
_ 开头list、type、next 等)文档字符串
工具检查
ruff check . 无报错ruff format --check . 无格式问题basedpyright 无类型错误覆盖率与完整性
可读性
print 语句残留可维护性
conftest.py复杂度
重复代码
可读性
if-elif(≥4 个分支)已替换为字典映射或 match-case数据结构
set 而非 listCounterdeque 而非 list性能
lru_cache / cache)join 而非 +=常见陷阱
def f(x=[]):)None 的比较使用 is/is not在审查结束时,按以下格式给出结论:
## 代码审查结论
### ✅ 符合标准的方面
- 类型注解完整,使用了 Python 3.10+ 语法
- 测试遵循 AAA 模式,命名清晰
- ...
### ⚠️ 需要改进的方面
1. `process_data()` 函数缺少返回值类型注解
- 位置:`src/processor.py:42`
- 建议:添加 `-> list[Result]`
2. 测试覆盖率不足
- 位置:`tests/test_processor.py`
- 建议:补充异常路径测试(当输入为空列表时)
3. 魔法数字
- 位置:`src/config.py:15`:`if retries > 3:`
- 建议:提取为常量 `MAX_RETRIES = 3`
### 🚫 必须修复的问题(阻断合并)
- `basedpyright` 报告 2 个类型错误(见下方详情)
- `ruff` 报告 1 个 B006 错误(可变默认参数)
### 总体评分
- 代码风格:⭐⭐⭐⭐☆
- 测试质量:⭐⭐⭐☆☆
- 代码简洁性:⭐⭐⭐⭐⭐
- 最佳实践:⭐⭐⭐⭐☆
在提交或合并前运行以下命令确保基础质量:
# 格式化 + lint
ruff format .
ruff check . --fix
# 类型检查
basedpyright
# 运行相关测试(只跑本次修改涉及的模块)
pytest tests/test_affected_module.py -v
# 带覆盖率
pytest tests/test_affected_module.py --cov=src/affected_module --cov-report=term-missing