mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-29 18:46:52 +00:00
Correct exclude paths in git hook
When running the git hook, even though the appropriate config file is found and processed, the exclude patterns and paths were not being corrected to account for the temporary directory that we copy the files into. Related-to #223
This commit is contained in:
parent
3fecbe177d
commit
2197c2ea15
1 changed files with 9 additions and 0 deletions
|
|
@ -42,6 +42,7 @@ def hook(lazy=False, strict=False):
|
|||
with make_temporary_directory() as tempdir:
|
||||
filepaths = list(copy_indexed_files_to(tempdir, lazy))
|
||||
app.initialize(['.'])
|
||||
app.options.exclude = update_excludes(app.options.exclude, tempdir)
|
||||
app.run_checks(filepaths)
|
||||
|
||||
app.report_errors()
|
||||
|
|
@ -194,6 +195,14 @@ def config_for(parameter):
|
|||
return value.lower() in defaults.TRUTHY_VALUES
|
||||
|
||||
|
||||
def update_excludes(exclude_list, temporary_directory_path):
|
||||
return [
|
||||
(temporary_directory_path + pattern)
|
||||
if os.path.isabs(pattern) else pattern
|
||||
for pattern in exclude_list
|
||||
]
|
||||
|
||||
|
||||
_HOOK_TEMPLATE = """#!{executable}
|
||||
import os
|
||||
import sys
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue