Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/docformatter/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ def is_excluded(name, excluded):
dirs[:] = []
continue

dirs[:] = [
d for d in dirs if not is_hidden(d) and not is_excluded(d, exclude)
]

files = sorted(
[
_file
Expand Down
19 changes: 19 additions & 0 deletions tests/test_utility_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,22 @@ def test_find_py_files_skips_excluded_directory_and_continues(tmp_path):
result = list(find_py_files([str(root)], recursive=True, exclude=["a_excluded"]))

assert result == [str(included / "included.py")]


@pytest.mark.unit
def test_find_py_files_skips_hidden_directory_recursive(tmp_path):
"""Skip hidden directories when recursing even if not in exclude."""
root = tmp_path / "project"
hidden = root / ".hidden"
nested_hidden = hidden / "nested"
visible = root / "visible"
nested_hidden.mkdir(parents=True)
visible.mkdir(parents=True)
(hidden / "hidden.py").touch()
(nested_hidden / "nested.py").touch()
(visible / "visible.py").touch()

result = list(find_py_files([str(root)], recursive=True, exclude=None))

assert result == [str(visible / "visible.py")]

Loading