Skip to content

Commit

Permalink
Skip subdirectories of hidden directories
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPapadopoulos committed Mar 16, 2023
1 parent a239c80 commit 1dcd675
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,12 @@ def main(*args: str) -> int:
)

# skip (relative) directories
dirs[:] = [dir_ for dir_ in dirs if not glob_match.match(dir_)]
dirs[:] = [
dir_
for dir_ in dirs
if not glob_match.match(dir_)
and not is_hidden(dir_, options.check_hidden)
]

elif not glob_match.match(filename): # skip files
bad_count += parse_file(
Expand Down
3 changes: 3 additions & 0 deletions codespell_lib/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,9 @@ def test_check_hidden(
hidden_dir = tmp_path / ".abandonned"
hidden_dir.mkdir()
copyfile(typo_file, hidden_dir / typo_file.name)
hidden_subdir = hidden_dir / "subdir"
hidden_subdir.mkdir()
copyfile(typo_file, hidden_subdir / typo_file.name)
assert cs.main(tmp_path) == 0
assert cs.main("--check-hidden", tmp_path) == 2
assert cs.main("--check-hidden", "--check-filenames", tmp_path) == 5
Expand Down

0 comments on commit 1dcd675

Please sign in to comment.