Remove `components` and `ancestry`, and make `prune_dirs` Path-only
Author: snejusCreated Sep 1, 2026Updated Sep 29, 2026
Labelscore
Part of: #1409
Depends on: #6809.
Problem
beets.util.components, beets.util.ancestry, and the byte-compatible prune_dirs implementation duplicate behavior that Path already provides. Keeping these helpers after runtime paths are Path-native makes utility code harder to reason about and leaves another place where bytes can enter filesystem logic.
Expected behavior
- Replace
componentscallers withPath.partsor equivalent localPathoperations. - Replace
ancestrycallers withPath.parentsor equivalent localPathoperations. - Make
prune_dirsacceptPathfor both the target directory and optional root. - Keep clutter matching behavior unchanged.
- Remove tests that only validate the deleted compatibility helpers, while preserving coverage for the behavior that still exists.
Suggested fix
Remove the obsolete decomposition helpers first, then simplify prune_dirs around Path.exists, Path.iterdir, Path.parents, and shutil.rmtree.
Acceptance criteria
- No production or test code imports
componentsorancestry. prune_dirscallers passPath.- Directory pruning behavior remains covered by tests.
poe testandpoe lintpass with coverage at or above 80%.
Source: beetbox/beets