Remove `components` and `ancestry`, and make `prune_dirs` Path-only
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 2.1k
- Avg merge
- 4d 21h
- Merged PRs (30d)
- 31
Description
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 `components` callers with `Path.parts` or equivalent local `Path` operations.
- Replace `ancestry` callers with `Path.parents` or equivalent local `Path` operations.
- Make `prune_dirs` accept `Path` for 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 `components` or `ancestry`.
- `prune_dirs` callers pass `Path`.
- Directory pruning behavior remains covered by tests.
- `poe test` and `poe lint` pass with coverage at or above 80%.
Contributor guide
Research direction
Search production and test code for beets.util.components, beets.util.ancestry, and prune_dirs, then trace the existing directory-pruning tests and callers. Replace the helper usage with Path operations, keep clutter matching and pruning behavior covered, and run poe test and poe lint with at least 80% coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 63/100