Enable pathlib lint and clean up remaining `os.path` usage
Author: snejusCreated Sep 1, 2026Updated Sep 29, 2026
Labelscore
Part of: #1409
Depends on: legacy byte-path helper removal.
Problem
After the path contracts are migrated, remaining os.path, builtin open, and path-style os calls make it easy to reintroduce string path manipulation. The project needs lint coverage to keep new code on the Path API and to expose leftover mechanical cleanup.
Expected behavior
- Enable Ruff
PTHrules for production code where practical. - Replace remaining mechanical
os.pathoperations withPathmethods. - Use
Path.open,Path.read_text,Path.write_text,Path.exists,Path.is_file,Path.unlink, and related methods where they preserve behavior. - Keep explicit ignores only where the code intentionally operates on path fragments, external formats, or non-filesystem strings.
- Document any remaining ignores with a short reason.
Suggested fix
Turn on PTH after semantic migration is complete, then handle the remaining warnings as mechanical cleanup. Keep intentional exceptions narrow so future byte/string path drift remains visible.
Acceptance criteria
- Ruff pathlib rules are enabled for the intended scope.
- Remaining
PTHignores are targeted and justified. - Tests cover behavior for any non-mechanical replacement.
poe testandpoe lintpass with coverage at or above 80%.
Source: beetbox/beets