Skip to content

Instantly share code, notes, and snippets.

@yasinuygun
Last active August 8, 2023 12:47
Show Gist options
  • Save yasinuygun/5d0dc399d3346113e2b77504c3d6b250 to your computer and use it in GitHub Desktop.
Save yasinuygun/5d0dc399d3346113e2b77504c3d6b250 to your computer and use it in GitHub Desktop.
yapf pre-commit git hook
#!/bin/sh
# Run yapf on modified Python files
files=$(git diff --cached --name-only --diff-filter=AM | grep -E '\.py$')
if [ -n "$files" ]; then
yapf --style "{based_on_style: pep8, column_limit: 120}" -i $files
git add $files
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment