Skip to content

Commit 4c033a1

Browse files
authored
Merge pull request #111 from tybug/perf
Improve `shed` speed in the presence of large dot directories
2 parents 6471da7 + 38298d2 commit 4c033a1

File tree

5 files changed

+26
-4
lines changed

5 files changed

+26
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changelog
22
*`shed` uses [calendar versioning](https://calver.org/), with a year.month.patch scheme.*
33

4+
#### 2025.6.1 - 2025-06-05
5+
- Improve performance in large repositories, by skipping directories that start with `.` during an internal check.
6+
47
#### 2024.10.1 - 2024-04-27
58
- Disable `PIE790` fix due to [ruff issue #10538](https://github.com/astral-sh/ruff/issues/10538)
69
- [Python 3.8 has reached end-of-life](https://devguide.python.org/versions/),

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ adding the following to your `.pre-commit-config.yaml`:
5959
minimum_pre_commit_version: '2.9.0'
6060
repos:
6161
- repo: https://github.com/Zac-HD/shed
62-
rev: 2024.10.1
62+
rev: 2025.6.1
6363
hooks:
6464
- id: shed
6565
# args: [--refactor, --py311-plus]

src/shed/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from black.mode import TargetVersion
2020
from black.parsing import lib2to3_parse
2121

22-
__version__ = "2024.10.1"
22+
__version__ = "2025.6.1"
2323
__all__ = ["shed", "docshed"]
2424

2525
# Conditionally imported in refactor mode to reduce startup latency in the common case

src/shed/_cli.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,26 @@ def _guess_first_party_modules(cwd: Optional[str] = None) -> FrozenSet[str]:
4747
base = _get_git_repo_root(cwd)
4848
except (subprocess.SubprocessError, FileNotFoundError):
4949
return frozenset()
50-
provides = {init.parent.name for init in Path(base).glob("**/src/*/__init__.py")}
50+
51+
def _walk_path(path: Path) -> set[str]:
52+
provides = set()
53+
try:
54+
for p in path.iterdir():
55+
if p.name.startswith(".") or not p.is_dir():
56+
continue
57+
if p.name == "src":
58+
provides |= {init.parent.name for init in p.glob("*/__init__.py")}
59+
# in case of nested src/ directories, like
60+
# src/tools/src/helper/__init__.py
61+
provides |= _walk_path(p)
62+
else:
63+
provides |= _walk_path(p)
64+
except Exception: # pragma: no cover
65+
pass
66+
67+
return provides
68+
69+
provides = _walk_path(Path(base))
5170
return frozenset(
5271
p
5372
for p in {Path(base).name} | provides

src/shed/_is_python_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def _detect_encoding(
7272

7373

7474
def _inner_detect_encoding(
75-
readline: Callable[[], bytes | bytearray]
75+
readline: Callable[[], bytes | bytearray],
7676
) -> str: # pragma: no cover
7777
"""Return file encoding."""
7878
try:

0 commit comments

Comments
 (0)