# ============================================================ # pre-commit 钩子配置 # 安装:pip install -r requirements-dev.txt && pre-commit install # 手动全量运行:pre-commit run --all-files # ============================================================ repos: # ---- 通用钩子 ---- - repo: https://github.com/pre-commit/pre-commit-hooks rev: v5.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml - id: check-json - id: check-merge-conflict - id: debug-statements - id: detect-private-key # ip2region.xdb 约 10MB,放行大文件 - id: check-added-large-files args: ["--maxkb=12000"] # ---- Python 格式化:black ---- - repo: https://github.com/psf/black rev: 24.10.0 hooks: - id: black args: ["--line-length", "120"] # ---- import 排序:isort ---- - repo: https://github.com/PyCQA/isort rev: 5.13.2 hooks: - id: isort # ---- 静态检查:flake8 ---- - repo: https://github.com/PyCQA/flake8 rev: 7.1.1 hooks: - id: flake8