首页/ AI 技能 / @skilllib/skill-2014279394418700291
Skill站外收录 @skilllib/skill-2014279394418700291

annotations

提供对 Python 代码逐步添加类型注解的标准化流程,涵盖覆盖率检测、签名注解、静态类型检查、代码格式化、测试验证及结果确认,支持将高覆盖目录纳入自动化校验体系。

0.0 (0) 686 次安装 原作者 编程导航
收录于 2026-01-22
效率工具 AI 技能

Skills.MD

# Type Annotation Workflow We are gradually adding type annotations using Python 3.13+. ## Workflow 1. **Check current coverage**: ``` uv run plain code annotations <directory> --details ``` 2. **Add annotations**: Focus on function/method signatures (parameters and return types) 3. **Type check**: ``` ./scripts/type-check <directory> ``` 4. **Format**: `./scripts/fix` 5. **Test**: `./scripts/test <package>` 6. **Verify improvement**: ``` uv run plain code annotations <directory> ``` 7. **Add to validation**: Once a directory reaches 100% coverage, add it to `FULLY_TYPED_PATHS` in `scripts/type-validate` ## Guidelines - Add `from __future__ import annotations` when necessary - Focus on public APIs and user-facing methods first - Don't annotate `__init__` return types (type checkers infer `None`) - Use explicit `return None` for functions with `-> Type | None` return type - Some Django-style ORM patterns are inherently difficult to type - that's okay - Goal is progress, not perfection ## Example ```bash # Check coverage uv run plain code annotations plain/plain/assets --details # After adding annotations... ./scripts/type-check plain/plain/assets ./scripts/fix ./scripts/test plain uv run plain code annotations plain/plain/assets # Should show 100% ```

评论 0

还没有评论,来抢沙发。