Skip to content

Instantly share code, notes, and snippets.

@Ddedalus
Last active December 9, 2019 20:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ddedalus/1d561af72bd4afb1b7fec3dd2119c610 to your computer and use it in GitHub Desktop.
Save Ddedalus/1d561af72bd4afb1b7fec3dd2119c610 to your computer and use it in GitHub Desktop.
Run black and flake8 before each commit. Error on flake8 error
#!/usr/bin/env sh
# Pre commit hook
# autoformat
black -q .
# lint
flake_out="$(flake8 .)"
flake_code=$?
if [ $flake_code -ne 0 ]
then
echo "Pre-commit hook: flake8 exited with code $flake_code"
echo "$flake_out"
exit $flake_out
fi
exit 0
# Note: config for black and flake8 can be passed through relevant config files in the root directory of the repository
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment