diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 3eba1f2e7..e834fc4db 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -7,3 +7,15 @@ args: [-i] #inplace language: python types: [python] + +- id: yapf-diff + name: yapf-diff + description: "A formatter for Python files. (formats only changes included in commit)" + always_run: true + language: python + pass_filenames: false + stages: [pre-commit] + entry: | + bash -c "git diff -U0 --no-color --relative HEAD \ + | yapf-diff \ + | tee >(git apply --allow-empty -p0)"