#6968·beets

Migrate importer path APIs and state to `pathlib.Path`

Author: snejusCreated Sep 1, 2026Updated Sep 1, 2026

Part of: #1409

Depends on: the library-directory Path migration.

Problem

Importer code still passes paths through sessions, tasks, factories, and persisted import state using byte-oriented contracts. That keeps byte conversions scattered across import flow code and blocks tests from treating importer-owned paths as normal Path values.

Expected behavior

  • ImportSession, import tasks, task factories, and importer stages use Path for filesystem paths.
  • ImportTask.paths and related task state expose Path values at runtime.
  • sorted_walk and albums_in_dir use Path during importer directory discovery.
  • Persisted import state decodes legacy byte/string values when loading and stores only through an explicit serialization boundary.
  • Import UI and plugin event payloads receive Path values where they describe filesystem paths.
  • Existing behavior for resumable imports, duplicate detection, art lookup, and plugin hooks is preserved.

Suggested fix

Migrate importer state and task types together so each importer path has one runtime representation. Keep encoding and decoding local to state persistence and any external format that still requires primitive values.

Acceptance criteria

  • Importer path APIs no longer require caller-side os.fsencode or os.fsdecode.
  • Importer directory discovery works with Path-based sorted_walk and albums_in_dir.
  • Legacy import state remains readable.
  • Importer tests and affected plugin tests use Path at the runtime boundary.
  • poe test and poe lint pass with coverage at or above 80%.