python-code-stylecommit cbb6049SKILL.md · 代码规范
Python 代码风格
说明 Python 的 lint 与格式化工具配置、PEP 8 命名、导入顺序、类型注解和 Google 风格 docstring 规范。
npx skills add wshobson/agents --skill python-code-style已选中命令,请手动复制。
- 权限
- read-repo
- write-files
- shell
- network
- 兼容工具
- Claude Code, Codex, Cursor, Copilot, OpenCode
- GitHub
- 42.1k
- 来源
- 社区 · Seth Hobson
- 状态
- 扫描通过
- 许可证
- MIT
- 分类
- 代码规范
核心规则
格式之争交给工具:一次配置,自动执行。
执行阶段
阶段 01配置工具
在 pyproject.toml 中配置 ruff 负责 lint 和格式化,并启用严格模式的 mypy 或 pyright。
阶段 02命名与导入
遵循 PEP 8,名称清晰优先于简短;导入按标准库、第三方、本地分组,只用绝对导入。
阶段 03类型与文档
为所有公共 API 添加类型注解和 Google 风格 docstring,写明 Args、Returns、Raises 和示例。
阶段 04格式与项目文档
行宽设为 120,合理换行;按模板维护 README 和 Keep a Changelog 格式的 CHANGELOG,并在 CI 中运行 linter。
权限说明(据 SKILL.md 整理)
| 能力 | 是否需要 | 说明 |
|---|---|---|
| 文件写入 | 需要 | 修改 pyproject.toml 等配置、为代码补充类型和 docstring,并编写项目文档。 |
| 命令执行 | 部分需要 | 运行 ruff check --fix、ruff format 以及安装 ruff、mypy 等工具的命令。 |
| 网络外发 | 部分需要 | 仅在用 pip 安装 ruff、mypy 等工具时访问软件包索引。 |
SKILL.md 头部信息(YAML)
---
name: python-code-style
description: Python code style, linting, formatting, naming conventions, and documentation standards. Use when writing new code, reviewing style, configuring linters, writing docstrings, or establishing project standards.
---相关技能
规则扫描无法覆盖所有风险,安装前请阅读此技能的 SKILL.md,确认权限后再使用。