1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
# File configures YAPF to be used as a git hook with https://github.com/pre-commit/pre-commit
- id: yapf
name: yapf
description: "A formatter for Python files."
entry: yapf
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)"
|