Skip to content

Instantly share code, notes, and snippets.

@satetheus
Last active June 27, 2019 06:11
Show Gist options
  • Save satetheus/4cd68edb6705264f2f3ff3a7c6454ee3 to your computer and use it in GitHub Desktop.
Save satetheus/4cd68edb6705264f2f3ff3a7c6454ee3 to your computer and use it in GitHub Desktop.
pre-commit git hook for testing pep8 conformity
#! /usr/bin/env bash
if python -m pycodestyle {,**/}*.py | grep [a-z,0-9];
then
exit 1;
else
exit 0;
fi
#! /usr/bin/env bash
if python3 -m pycodestyle {,**/}*.py | grep [a-z,0-9];
then
exit 1;
else
exit 0;
fi
@satetheus
Copy link
Author

satetheus commented Jun 27, 2019

I added 'python -m' before the pycodestyle for easier portability on different os. If only one version of python is installed, the pre-commit file is suitable. Otherwise, for systems with both python2 & python3, the python3 specific pre-commit will be necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment