Skip to content

Instantly share code, notes, and snippets.

@viyatb
Last active August 29, 2015 13:57
Show Gist options
  • Save viyatb/9871814 to your computer and use it in GitHub Desktop.
Save viyatb/9871814 to your computer and use it in GitHub Desktop.
PEP8 p re-commit hook for OWTF
#!/bin/sh
# Auto-check for pep8 and flake8 proposed formatting checks automatically before committing bad code
# requires flake8 module
# The following is a list of the most common PEP 8 errors and warnings; to
# skip some just add them to the IGNORE variable (comma separated):
# E111 indentation is not a multiple of four
# E123 closing bracket does not match indentation of opening bracket's line
# E201 whitespace after '('
# E202 whitespace before ')'
# E203 whitespace before ','
# E211 whitespace before '('
# E221 multiple spaces before operator
# E222 multiple spaces after operator
# E225 missing whitespace around operator
# E231 missing whitespace after ':'
# E251 no spaces around keyword / parameter equals
# E261 at least two spaces before inline comment
# E271 multiple spaces after keyword
# E272 multiple spaces before keyword
# E301 expected 1 blank line, found 0
# E302 expected 2 blank lines, found 1
# E303 too many blank lines (3)
# E401 multiple imports on one line
# E501 line too long (80 characters)
# E701 multiple statements on one line (colon)
# W291 trailing whitespace
# W293 blank line contains whitespace
# W391 blank line at end of file
# W601 .has_key() is deprecated, use 'in'
# W602 deprecated form of raising exception
# W604 backticks are deprecated, use 'repr()'
FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -e '\.py$')
if [ -n "$FILES" ]; then
flake8 -r $FILES
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment