mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-07 13:36:54 +00:00
parent
9553c8d8cc
commit
08332273e0
1 changed files with 14 additions and 0 deletions
|
|
@ -14,6 +14,7 @@ import tempfile
|
|||
|
||||
from flake8 import defaults
|
||||
from flake8 import exceptions
|
||||
from flake8.options.config import ConfigFileFinder
|
||||
|
||||
__all__ = ('hook', 'install')
|
||||
|
||||
|
|
@ -41,6 +42,7 @@ def hook(lazy=False, strict=False):
|
|||
app = application.Application()
|
||||
with make_temporary_directory() as tempdir:
|
||||
filepaths = list(copy_indexed_files_to(tempdir, lazy))
|
||||
copy_configuration_files_to(tempdir)
|
||||
app.initialize(filepaths)
|
||||
app.run_checks()
|
||||
|
||||
|
|
@ -121,6 +123,12 @@ def copy_indexed_files_to(temporary_directory, lazy):
|
|||
yield copy_file_to(temporary_directory, filename, contents)
|
||||
|
||||
|
||||
def copy_configuration_files_to(temporary_directory):
|
||||
configuration_files = find_configuration_files()
|
||||
for filename in configuration_files:
|
||||
shutil.copy(filename, temporary_directory)
|
||||
|
||||
|
||||
def copy_file_to(destination_directory, filepath, contents):
|
||||
directory, filename = os.path.split(os.path.abspath(filepath))
|
||||
temporary_directory = make_temporary_directory_from(destination_directory,
|
||||
|
|
@ -153,6 +161,12 @@ def find_modified_files(lazy):
|
|||
return stdout.splitlines()
|
||||
|
||||
|
||||
def find_configuration_files():
|
||||
for f in ConfigFileFinder.PROJECT_FILENAMES:
|
||||
if os.path.isfile(f):
|
||||
yield f
|
||||
|
||||
|
||||
def get_staged_contents_from(filename):
|
||||
git_show = piped_process(['git', 'show', ':{0}'.format(filename)])
|
||||
(stdout, _) = git_show.communicate()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue