# 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 ```