Skip to content

Make path utilities generic over string path types #6808

Description

@snejus

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions