Parent issue: #1409
Problem
Many beets path utilities are typed or implemented around byte paths and sometimes coerce inputs to bytes. This prevents callers from migrating incrementally to string and Path representations because a helper may reject the new input type or unexpectedly return bytes.
Expected behavior
- Make path-producing helpers generic over
str and bytes, preserving the caller's concrete path type in returned or yielded values.
- Broaden filesystem-action helpers to accept
PathLike when their return type does not depend on the input path type.
- Apply this to the utilities including
mkdirall, samefile, copy, move, link, hardlink, reflink, case_sensitive, unique_path, sorted_walk, hidden.is_hidden, and albums_in_dir.
- Keep ignore patterns, regular expressions, path components, and recursive calls type-consistent so bytes and strings are never mixed at runtime.
- Retain explicit byte conversion only at boundaries whose contracts require bytes.
- Preserve existing filesystem behavior.
Acceptance criteria
- Each affected utility accepts the intended string, byte, or general path-like inputs without type errors.
- Helpers whose outputs are derived from their inputs preserve
str or bytes consistently.
This work must land before migrating the broader test suite to pathlib.Path.
Parent issue: #1409
Problem
Many beets path utilities are typed or implemented around byte paths and sometimes coerce inputs to
bytes. This prevents callers from migrating incrementally to string andPathrepresentations because a helper may reject the new input type or unexpectedly return bytes.Expected behavior
strandbytes, preserving the caller's concrete path type in returned or yielded values.PathLikewhen their return type does not depend on the input path type.mkdirall,samefile,copy,move,link,hardlink,reflink,case_sensitive,unique_path,sorted_walk,hidden.is_hidden, andalbums_in_dir.Acceptance criteria
strorbytesconsistently.This work must land before migrating the broader test suite to
pathlib.Path.