Last active
August 29, 2015 13:56
-
-
Save splanquart/8872168 to your computer and use it in GitHub Desktop.
pre-commit git hook to run flask before each commit
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/python | |
import sys | |
from flake8.engine import get_style_guide as get_style_guide | |
import os | |
import shutil | |
from tempfile import mkdtemp | |
from flake8.main import DEFAULT_CONFIG | |
COMPLEXITY = 10 | |
STRICT = True | |
IGNORE = ['E501'] | |
# before install tip this line out of your virtual env and install flake8 | |
# sudo pip install flake8 | |
# you can install it from command line by tip this line | |
# curl -o pre-commit https://gist.github.com/splanquart/8872168/raw; chmod +x pre-commit ;mv pre-commit .git/hooks/ | |
# patch flake8 git_hook | |
def get_style_guide2(**kwargs): | |
del kwargs['parse_argv'] | |
return get_style_guide(**kwargs) | |
import flake8.hooks | |
flake8.hooks.get_style_guide = get_style_guide2 | |
from flake8.hooks import git_hook | |
if __name__ == '__main__': | |
sys.exit(git_hook(complexity=COMPLEXITY, strict=STRICT, ignore=IGNORE)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment