1# File configures YAPF to be used as a git hook with https://github.com/pre-commit/pre-commit 2 3- id: yapf 4 name: yapf 5 description: "A formatter for Python files." 6 entry: yapf 7 args: [-i] #inplace 8 language: python 9 types: [python] 10 11- id: yapf-diff 12 name: yapf-diff 13 description: "A formatter for Python files. (formats only changes included in commit)" 14 always_run: true 15 language: python 16 pass_filenames: false 17 stages: [pre-commit] 18 entry: | 19 bash -c "git diff -U0 --no-color --relative HEAD \ 20 | yapf-diff \ 21 | tee >(git apply --allow-empty -p0)" 22