diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py index 49a62a3996a..d64cc733b89 100644 --- a/codespell_lib/_codespell.py +++ b/codespell_lib/_codespell.py @@ -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( diff --git a/codespell_lib/tests/test_basic.py b/codespell_lib/tests/test_basic.py index f40a7ae04d4..cabbab9ed02 100644 --- a/codespell_lib/tests/test_basic.py +++ b/codespell_lib/tests/test_basic.py @@ -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