Skip to content

Instantly share code, notes, and snippets.

@xtranophilist
Forked from ptone/gist:4102528
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xtranophilist/eca5acae1a33b0baad33 to your computer and use it in GitHub Desktop.
Save xtranophilist/eca5acae1a33b0baad33 to your computer and use it in GitHub Desktop.
Git pre-commit hook for Python
#!/usr/bin/env python
import glob
import os
import sys
# git usurbs your bin path for hooks and will always run system python
site_packages = glob.glob('%s/lib/*/site-packages' % os.environ['VIRTUAL_ENV'])[0]
sys.path.insert(0, site_packages)
from flake8.run import git_hook
COMPLEXITY = os.getenv('FLAKE8_COMPLEXITY', 10)
STRICT = os.getenv('FLAKE8_STRICT', True)
IGNORE = os.getenv('FLAKE8_IGNORE', 'E501')
LAZY = os.getenv('FLAKE8_LAZY', False)
if __name__ == '__main__':
sys.exit(git_hook(
complexity=COMPLEXITY,
strict=STRICT,
ignore=IGNORE,
lazy=LAZY,
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment