Last active
January 24, 2017 04:26
-
-
Save squamous/8501228069a360fcd219930c14d55ccc to your computer and use it in GitHub Desktop.
Pre-commit git hook to lint all python files
This file contains hidden or 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
#!/bin/sh | |
# works as of flake8 3.2.1 | |
echo -n "Enter the project directory and press [Enter]: " | |
read project | |
if [ ! -d $project ]; then | |
echo "FAILURE: Could not find directory '$project'" | |
fi | |
cd $project | |
echo '* Installing flake8 git pre-commit hook\n' | |
flake8 --install-hook git | |
echo "* configuring flake8 to forbid commits containing errors/warnings\n" | |
git config --bool flake8.strict true | |
echo "* setting some flake8 config options in your project's tox.ini" | |
cat << 'EOF' >> tox.ini | |
[flake8] | |
max-line-length = 120 | |
ignore = F403 | |
exclude = *migrations*,venv | |
EOF | |
tail -n 4 tox.ini | |
echo '\n* Done' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment