#6972·beets

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 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%.