Last active
June 27, 2019 06:11
-
-
Save satetheus/4cd68edb6705264f2f3ff3a7c6454ee3 to your computer and use it in GitHub Desktop.
pre-commit git hook for testing pep8 conformity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
if python -m pycodestyle {,**/}*.py | grep [a-z,0-9]; | |
then | |
exit 1; | |
else | |
exit 0; | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
if python3 -m pycodestyle {,**/}*.py | grep [a-z,0-9]; | |
then | |
exit 1; | |
else | |
exit 0; | |
fi |
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
Requires bash v4.0+ (or gitbash for windows) & pycodestyle