mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-14 08:24:46 +00:00
Don't apply excludes greedily to subdirs
This commit is contained in:
parent
733a4f053b
commit
0559e0b43c
2 changed files with 16 additions and 1 deletions
|
|
@ -246,7 +246,7 @@ def filenames_from(arg, predicate=None):
|
||||||
# remove it from the list of sub-directories.
|
# remove it from the list of sub-directories.
|
||||||
for directory in sub_directories:
|
for directory in sub_directories:
|
||||||
joined = os.path.join(root, directory)
|
joined = os.path.join(root, directory)
|
||||||
if predicate(directory) or predicate(joined):
|
if predicate(joined):
|
||||||
sub_directories.remove(directory)
|
sub_directories.remove(directory)
|
||||||
|
|
||||||
for filename in files:
|
for filename in files:
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,21 @@ def test_filenames_from_a_single_file():
|
||||||
assert ['flake8/__init__.py'] == filenames
|
assert ['flake8/__init__.py'] == filenames
|
||||||
|
|
||||||
|
|
||||||
|
def test_filenames_from_exclude_doesnt_exclude_directory_names(tmpdir):
|
||||||
|
"""Verify that we don't greedily exclude subdirs."""
|
||||||
|
tmpdir.join('1').ensure_dir().join('dont_return_me.py').ensure()
|
||||||
|
tmpdir.join('2').join('1').ensure_dir().join('return_me.py').ensure()
|
||||||
|
exclude = [tmpdir.join('1').strpath]
|
||||||
|
|
||||||
|
# This acts similar to src.flake8.checker.is_path_excluded
|
||||||
|
def predicate(pth):
|
||||||
|
return utils.fnmatch(os.path.abspath(pth), exclude)
|
||||||
|
|
||||||
|
with tmpdir.as_cwd():
|
||||||
|
filenames = list(utils.filenames_from('.', predicate))
|
||||||
|
assert filenames == [os.path.join('.', '2', '1', 'return_me.py')]
|
||||||
|
|
||||||
|
|
||||||
def test_parameters_for_class_plugin():
|
def test_parameters_for_class_plugin():
|
||||||
"""Verify that we can retrieve the parameters for a class plugin."""
|
"""Verify that we can retrieve the parameters for a class plugin."""
|
||||||
class FakeCheck(object):
|
class FakeCheck(object):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue