summaryrefslogtreecommitdiff
path: root/flake8/hooks.py
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2015-03-06 23:26:44 -0600
committerIan Cordasco <graffatcolmingov@gmail.com>2015-03-06 23:26:44 -0600
commit7ab30a747fbb17af7ef45901f647c21603f44bfc (patch)
tree5bf9443c8883ae68b8bb2d484e47d069600772a6 /flake8/hooks.py
parentc084211e9e9c48fc40ff2c33a9a4fc69960445ea (diff)
parent84c8dd5e8d192a2ed6c0555a2d00164934266ba3 (diff)
downloadflake8-7ab30a747fbb17af7ef45901f647c21603f44bfc.tar.gz
Merge branch 'local/pr/2'
Conflicts: flake8/hooks.py
Diffstat (limited to 'flake8/hooks.py')
-rw-r--r--flake8/hooks.py22
1 files changed, 9 insertions, 13 deletions
diff --git a/flake8/hooks.py b/flake8/hooks.py
index 125e3cb..e938632 100644
--- a/flake8/hooks.py
+++ b/flake8/hooks.py
@@ -6,7 +6,7 @@ import sys
import stat
from subprocess import Popen, PIPE
import shutil
-from tempfile import mkdtemp
+import tempfile
try:
from configparser import ConfigParser
except ImportError: # Python 2
@@ -48,15 +48,10 @@ def git_hook(complexity=-1, strict=False, ignore=None, lazy=False):
if complexity > -1:
options['max_complexity'] = complexity
- tmpdir = mkdtemp()
+ tmpdir = tempfile.mkdtemp()
flake8_style = get_style_guide(config_file=DEFAULT_CONFIG, paths=['.'],
**options)
- # Since we use a temporary directory, the exclude path needs to be fixed
- # to prepend that.
- path_join = os.path.join
- flake8_style.options.exclude = [path_join(tmpdir, x) if "/" in x else x
- for x in flake8_style.options.exclude]
filepatterns = flake8_style.options.filename
# Copy staged versions to temporary directory
@@ -74,15 +69,16 @@ def git_hook(complexity=-1, strict=False, ignore=None, lazy=False):
dirname = os.path.join(tmpdir, dirname)
if not os.path.isdir(dirname):
os.makedirs(dirname)
- filename = os.path.join(dirname, filename)
- # write staged version of file to temporary directory
- with open(filename, "wb") as fh:
- fh.write(out)
# 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))):
+ if ((pep8.filename_match(file_, filepatterns) and
+ not flake8_style.excluded(file_))):
+
+ filename = os.path.join(dirname, filename)
files_to_check.append(filename)
+ # write staged version of file to temporary directory
+ with open(filename, "wb") as fh:
+ fh.write(out)
# Run the checks
report = flake8_style.check_files(files_to_check)