summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2014-10-03 14:01:18 +0000
committerIan Cordasco <graffatcolmingov@gmail.com>2014-10-03 14:01:18 +0000
commit752790e4ea9b5252d0484d9951dc0f4d777ec4e6 (patch)
tree18fba3420e3ffa501ed3dfe257765f50d194ac1a
parent876e283d38bcc2b82590b8547bb89552027b7949 (diff)
parentc0dd7c870c294db1e5db04ca7549c7e3bba021cb (diff)
downloadflake8-752790e4ea9b5252d0484d9951dc0f4d777ec4e6.tar.gz
Merge branch 'git_hook-file_pattern_match' into 'master'
Git hook file pattern match I found that with the git hook installed, flake8 was failing to check some files. Upon examination, I found that the hook is coded to only consider files ending in '.py'. This works out to be an override of the expected behavior, which is to honor the "filename" option in tox.ini. See merge request !1
-rw-r--r--flake8/hooks.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/flake8/hooks.py b/flake8/hooks.py
index 9542279..1cbe884 100644
--- a/flake8/hooks.py
+++ b/flake8/hooks.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import with_statement
import os
+import pep8
import sys
import stat
from subprocess import Popen, PIPE
@@ -47,10 +48,9 @@ def git_hook(complexity=-1, strict=False, ignore=None, lazy=False):
if complexity > -1:
options['max_complexity'] = complexity
- files_modified = [f for f in files_modified if f.endswith('.py')]
-
flake8_style = get_style_guide(config_file=DEFAULT_CONFIG, paths=['.'],
**options)
+ filepatterns = flake8_style.options.filename
# Copy staged versions to temporary directory
tmpdir = mkdtemp()
@@ -72,7 +72,12 @@ def git_hook(complexity=-1, strict=False, ignore=None, lazy=False):
# write staged version of file to temporary directory
with open(filename, "wb") as fh:
fh.write(out)
- files_to_check.append(filename)
+
+ # check_files() only does this check if passed a dir; so we do it
+ if ((pep8.filename_match(filename, filepatterns) and
+ not flake8_style.excluded(filename))):
+ files_to_check.append(filename)
+
# Run the checks
report = flake8_style.check_files(files_to_check)
# remove temporary directory