template evaluation: handle string templates only#6737
Open
snejus wants to merge 1 commit into
Open
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. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6737 +/- ##
==========================================
- Coverage 74.54% 74.51% -0.03%
==========================================
Files 162 162
Lines 20832 20820 -12
Branches 3298 3295 -3
==========================================
- Hits 15529 15515 -14
- Misses 4548 4549 +1
- Partials 755 756 +1
🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
grug see PR make template eval go through one string path: evaluate_fmt(...). goal is less “string vs Template object” branching.
Changes:
- rename model templating API to string-only
evaluate_fmt(fmt, for_path=...)and route eval throughget_template(...)cache - switch
path_formatsplumbing to carry raw format strings (no compiledTemplateobjects) - update callers (library/models, modify command, smartplaylist, bench, tests) to pass strings
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| test/test_library.py | switch item template eval assertions to evaluate_fmt |
| test/plugins/test_types_plugin.py | switch template conditionals tests to evaluate_fmt |
| test/plugins/test_smartplaylist.py | update smartplaylist mocks to evaluate_fmt (but currently broken w/ kwargs + bytes) |
| test/plugins/test_rewrite.py | switch album template eval assertion to evaluate_fmt |
| test/plugins/test_inline.py | switch inline plugin test to evaluate_fmt |
| beetsplug/smartplaylist.py | use evaluate_fmt(..., for_path=True) for playlist name + debug formatting |
| beetsplug/bench.py | set lib.path_formats entries to raw format strings |
| beets/util/pathformats.py | make get_path_formats return (key, fmt_str) pairs |
| beets/util/functemplate.py | centralize compilation/cache under get_template(fmt) |
| beets/ui/commands/modify.py | remove per-run template compile dict; call evaluate_fmt directly |
| beets/library/models.py | switch formatting and path destination building to evaluate_fmt |
| beets/dbcore/db.py | replace evaluate_template with evaluate_fmt using get_template |
23faa20 to
151fc58
Compare
- Handle formats as strings ONLY and evaluate them through a shared cached template helper. - This removes the need for conditional logic that acts on Template objects or strings.
151fc58 to
10f49d1
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.
What changed
evaluate_fmt(...).Templateobjects.beets.util.functemplate.get_template(...).Architecture impact
dbcorenow owns one clear path for evaluating format strings.path_formatsnow carriestuple[str, str]values, which removes type branching in consumers.library,modify, and plugins now pass raw format strings and rely on the shared helper to compile/cache them.Why this matters
'string vs Template object'handling.