Move path formats and replacements logic into Library and shared util#6647
Open
snejus wants to merge 5 commits into
Open
Move path formats and replacements logic into Library and shared util#6647snejus wants to merge 5 commits into
snejus wants to merge 5 commits into
Conversation
|
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. |
03551b8 to
0075269
Compare
82173d0 to
1bab999
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6647 +/- ##
==========================================
+ Coverage 72.46% 72.48% +0.02%
==========================================
Files 161 162 +1
Lines 20719 20727 +8
Branches 3280 3279 -1
==========================================
+ Hits 15014 15024 +10
+ Misses 4979 4978 -1
+ Partials 726 725 -1
🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
grug see PR move path format + replace rules out of UI layer into library + shared util. grug like: library own library things, UI just drive.
Changes:
- add
beets/util/pathformats.pyhelper for reading layeredpathsconfig (with query key expansion) - make
Library.path_formats+Library.replacementscome from config viacached_property, and simplify UI_open_library() - update convert + bench + tests to use new shared path format plumbing
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/util/test_pathformats.py | new focused pytest coverage for layered paths reading |
| test/ui/test_ui.py | remove UI-owned path format tests now covered elsewhere |
| test/test_library.py | make destination tests set explicit lib.path_formats to avoid depending on config defaults |
| beetsplug/convert.py | switch to shared get_path_formats + refactor destination calculation via helper |
| beetsplug/bench.py | use shared PF_KEY_DEFAULT constant for benchmark path formats |
| beets/util/pathformats.py | new shared path format constants + get_path_formats util |
| beets/ui/init.py | remove UI-owned get_path_formats/get_replacements; open Library without passing them |
| beets/library/queries.py | remove PF_KEY_DEFAULT constant from queries module |
| beets/library/models.py | import PF_KEY_DEFAULT from util instead of queries |
| beets/library/library.py | add cached_property path_formats + replacements derived from config |
Ensure that path_formats is set in relevant tests to avoid reliance on defaults and to clarify test intent. Update Library constructor type hint for path_formats to use Template type. This default value was only relevant in tests.
1bab999 to
290c5f8
Compare
290c5f8 to
5c2c530
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR moves path format and replacement retrieval out of
beets.uiinto library/shared utilities.Changes
beets/util/pathformats.pywithPF_KEY_DEFAULT,PF_KEY_QUERIES, andget_path_formats(subview).Library.path_formatsandLibrary.replacementsascached_propertyvalues derived from config.get_path_formats/get_replacementsand simplified_open_library()to constructLibrarywithout passing those values.beets/library/models.py,beetsplug/bench.py,beetsplug/convert.py) to use the shared path-format utility.ConvertPlugin.get_item_destination.test/util/test_pathformats.py..git-blame-ignore-revs.Why
pathsdefaults by iterating config via Confuseitems().