playbook/rulesets/python/index.md

48 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Python 代理规则集
本规则集定义 AI/自动化代理在处理 Python 代码时必须遵守的核心约束。
## 范围与优先级
- 作为仓库级基线规则集使用;更靠近代码目录的规则更具体并可覆盖基线。
- 当代理规则与 docs 冲突:安全/合规优先,其次保持仓库一致性。
## 代理工作原则(铁律)
1. 先理解目标与上下文,再动手改代码
2. 修改要小而清晰;避免无关重构
3. 发现安全问题(明文密钥/鉴权漏洞)立即标注或修复
4. 不引入新依赖或工具,除非明确要求
## Python 核心约定(不可违反)
- 代码风格Google Python Style Guide优先使用仓库既有配置`pyproject.toml`, `.flake8`, `.pylintrc`
- 工具链:未经沟通不切换 formatter/linter
- Import标准库 → 第三方 → 本地模块;分组间空行;避免 `import *`
- 命名:模块/包 `lower_with_under.py`;类 `CapWords`;函数/变量 `lower_with_under`;常量 `UPPER_WITH_UNDER`;私有 `_private`
- DocstringGoogle 风格;公共模块/类/函数/方法必须写
## 安全红线(不可触碰)
- 不得在代码/日志/注释中写入明文密钥、密码、Token、API Key
- 不得使用 `eval()` / `exec()` 处理不可信输入
- 修改鉴权/权限逻辑必须说明动机与风险
- 不确定是否敏感时按敏感信息处理
## 权威来源
- 代码风格:`docs/python/style_guide.md`
- 工具链:`docs/python/tooling.md`
- 配置清单:`docs/python/configuration.md`
## Skills按需加载
- `$testing-workflow`
- `$code-review-workflow`
- `$commit-message`
## 与开发规范的关系
- 本仓库内:`docs/python/` 与 `docs/common/`
- 目标项目 subtree`docs/standards/playbook/docs/python/` 与 `docs/standards/playbook/docs/common/`