Skip to content

Commit f79ce79

Browse files
Skip subdirectories of hidden directories
1 parent a050986 commit f79ce79

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

codespell_lib/_codespell.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,9 @@ def main(*args):
920920
uri_ignore_words, context, options)
921921

922922
# skip (relative) directories
923-
dirs[:] = [dir_ for dir_ in dirs if not glob_match.match(dir_)]
923+
dirs[:] = [dir_ for dir_ in dirs
924+
if not glob_match.match(dir_)
925+
and not is_hidden(dir_, options.check_hidden)]
924926

925927
elif not glob_match.match(filename): # skip files
926928
bad_count += parse_file(

codespell_lib/tests/test_basic.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,12 +391,17 @@ def test_check_hidden(tmpdir, capsys):
391391
assert cs.main(d) == 0
392392
assert cs.main('--check-hidden', d) == 1
393393
assert cs.main('--check-hidden', '--check-filenames', d) == 2
394-
os.mkdir(op.join(d, '.abandonned'))
394+
hidden_dir = op.join(d, '.abandonned')
395+
os.mkdir(hidden_dir)
395396
copyfile(op.join(d, '.abandonned.txt'),
396-
op.join(d, '.abandonned', 'abandonned.txt'))
397+
op.join(hidden_dir, 'abandonned.txt'))
398+
hidden_subdir = op.join(hidden_dir, 'subdir')
399+
os.mkdir(hidden_subdir)
400+
copyfile(op.join(d, '.abandonned.txt'),
401+
op.join(hidden_subdir, 'abandonned.txt'))
397402
assert cs.main(d) == 0
398-
assert cs.main('--check-hidden', d) == 2
399-
assert cs.main('--check-hidden', '--check-filenames', d) == 5
403+
assert cs.main('--check-hidden', d) == 3
404+
assert cs.main('--check-hidden', '--check-filenames', d) == 8
400405

401406

402407
def test_case_handling(tmpdir, capsys):

0 commit comments

Comments
 (0)