playbook/docs/python/tooling.md

37 lines
823 B
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 工具链Tooling
本 Playbook 推荐用以下工具保证代码一致性与质量:
- `black`:格式化(行宽 80
- `isort`import 排序Google profile
- `flake8`:风格检查 + docstring 约定
- `pylint`:静态检查(以 `.pylintrc` 为准,可按项目调整)
- `mypy`:类型检查(可选)
- `pytest`:测试(可选)
- `pre-commit`:在 `git commit` 前自动运行上述检查/格式化(可选,但推荐)
## 常用命令(示例)
安装工具(示例,按项目实际依赖管理方式调整):
```bash
python -m pip install black isort flake8 pylint mypy pytest pre-commit
```
格式化与检查(示例):
```bash
black .
isort .
flake8 .
pylint .
mypy .
pytest
```
启用 `pre-commit`(只需一次):
```bash
pre-commit install
```