Skip to content

utils: centralise path asciification#6733

Merged
snejus merged 2 commits into
masterfrom
include-unicodedata-in-asciify-path
Jul 3, 2026
Merged

utils: centralise path asciification#6733
snejus merged 2 commits into
masterfrom
include-unicodedata-in-asciify-path

Conversation

@snejus

@snejus snejus commented Jun 13, 2026

Copy link
Copy Markdown
Member
  • This change moves path Unicode normalization and separator cleanup into beets.util.asciify_path(), so path shaping now lives in one place instead of being split between beets.library.models and util.

  • Callers in Item.destination(), art_destination(), and tmpl_asciify() now use the same util.asciify_path() flow. This makes path generation more consistent and removes duplicate platform-specific normalization logic from the library layer.

  • High-level impact: when asciify_paths is enabled, all asciified paths now get the same normalization, transliteration, and separator-replacement behavior through one shared utility. This should make path handling easier to reason about and safer to change later.

  • Test coverage follows the architecture change: focused asciify behavior tests move from test/test_library.py to test/test_util.py, so asciify_path() is tested directly where the behavior now lives.

Copilot AI review requested due to automatic review settings June 13, 2026 00:39
@snejus snejus requested a review from a team as a code owner June 13, 2026 00:39
@github-actions

Copy link
Copy Markdown

Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

PR move Unicode normalize + separator cleanup into beets.util.asciify_path() so path shaping live one place, and library model call util for asciify.

Changes:

  • Change util.asciify_path() signature to read path_sep_replace from config and do platform Unicode normalization internally.
  • Update Item.destination(), Album.art_destination(), and tmpl_asciify() to call new util.asciify_path(subpath).
  • Move asciify-related tests out of test/test_library.py into new TestAsciifyPath in test/test_util.py.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
beets/util/__init__.py Centralize Unicode normalization + separator replacement inside asciify_path().
beets/library/models.py Switch callers to new asciify_path() signature and remove in-function normalization code.
test/test_library.py Remove destination/asciify tests that used to assert normalization behavior via Item.destination().
test/test_util.py Add direct tests for util.asciify_path() behavior.

Comment thread beets/library/models.py
Comment thread test/test_util.py Outdated
@codecov

codecov Bot commented Jun 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 74.83%. Comparing base (207d4bb) to head (8968648).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
beets/library/models.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6733   +/-   ##
=======================================
  Coverage   74.82%   74.83%           
=======================================
  Files         163      163           
  Lines       20969    20969           
  Branches     3302     3300    -2     
=======================================
+ Hits        15691    15693    +2     
+ Misses       4522     4521    -1     
+ Partials      756      755    -1     
Files with missing lines Coverage Δ
beets/util/__init__.py 80.63% <100.00%> (+1.00%) ⬆️
beets/library/models.py 87.71% <66.66%> (-0.10%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@snejus snejus force-pushed the include-unicodedata-in-asciify-path branch from c1999ba to 335e512 Compare June 27, 2026 22:22

@semohr semohr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine from my perspective. I think we lost a bit of test coverage here, maybe you want to check.

@snejus snejus force-pushed the include-unicodedata-in-asciify-path branch from 335e512 to f7cce1f Compare July 3, 2026 09:00
snejus added 2 commits July 3, 2026 18:59
- Move Unicode normalization and separator replacement into util.asciify_path.
- Update library callers and relocate focused asciify tests to util coverage.
@snejus snejus force-pushed the include-unicodedata-in-asciify-path branch from bc83804 to 8968648 Compare July 3, 2026 17:59
@snejus

snejus commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

Just fixed the coverage an expanded coverage of the function.

@snejus snejus merged commit 051485b into master Jul 3, 2026
22 checks passed
@snejus snejus deleted the include-unicodedata-in-asciify-path branch July 3, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants