Handle legacy fields in modify and queries#6494
Merged
Conversation
da2d4bb to
b41d349
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6494 +/- ##
==========================================
+ Coverage 70.15% 70.18% +0.02%
==========================================
Files 147 147
Lines 18662 18680 +18
Branches 3040 3042 +2
==========================================
+ Hits 13093 13111 +18
Misses 4927 4927
Partials 642 642
🚀 New features to boost your workflow:
|
85969e8 to
c77ea75
Compare
b41d349 to
13f48d1
Compare
c77ea75 to
a95fea1
Compare
13f48d1 to
6eb483c
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
PR make beet modify accept old singular multi-value field names, then rewrite to new plural field names and warn user, so user no longer make wrong custom field by accident.
Changes:
- Add central legacy->plural list field maps in
beets/util/deprecation.py - Reuse those maps from autotag
AlbumInfo/TrackInfoinstead of inline maps - Update
modify_parse_argsto rewrite legacy assignment keys + emit user-facing deprecation warning; add tests + docs
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
beets/util/deprecation.py |
Add shared legacy singular → plural list-field mapping constants. |
beets/autotag/hooks.py |
Switch Info subclasses to use shared mapping constants. |
beets/ui/commands/modify.py |
Rewrite legacy assignment keys to plural fields + warn user. |
test/ui/commands/test_modify.py |
Update call sites for new arg + add rewrite/warn tests. |
test/autotag/test_hooks.py |
Stop using Info directly in legacy-field tests; use TrackInfo. |
docs/reference/cli.rst |
Document legacy singular field support in modify. |
docs/changelog.rst |
Add changelog entry for modify legacy-field rewrite behavior. |
a95fea1 to
753c398
Compare
6eb483c to
43e4469
Compare
753c398 to
809cbca
Compare
43e4469 to
b5a59b5
Compare
809cbca to
392962e
Compare
b5a59b5 to
2427ad7
Compare
8997fa5 to
8c57b87
Compare
66977cf to
081f42b
Compare
081f42b to
02393c9
Compare
4f5331a to
de3054f
Compare
de3054f to
724891f
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.
Handle legacy singular field names in
modifyand queriesThis PR centralises the mapping of legacy singular field names (e.g.
genre,composer,lyricist,remixer,arranger) to their modern plural multi-valued equivalents (e.g.genres,composers, ...) and applies that rewrite in two places: themodifycommand and library field queries.What changed
beets/util/deprecation.py— new source of truthTwo module-level dicts,
ALBUM_LEGACY_TO_LIST_FIELDandITEM_LEGACY_TO_LIST_FIELD, now live here. A new helpermaybe_replace_legacy_field(field, is_album)wraps the lookup, emits a deprecation warning via the sharedlog, and returns the canonical field name.beets/library/models.py— queries now handle legacy fieldsfield_querycallsmaybe_replace_legacy_fieldbefore resolving whether the field is fast or slow. This means queries likegenre::rockorcomposer::bachare transparently rewritten and warn the user.beets/ui/commands/modify.py— simplified using the shared helperThe inline legacy-field lookup and
deprecate_for_usercall insidemodify_parse_argsare replaced with a single call tomaybe_replace_legacy_field. Theis_albumparameter is passed through frommodify_func.beets/autotag/hooks.py—LEGACY_TO_LIST_FIELDnow references the shared dictsAlbumInfoandTrackInfono longer define their own inline mappings; they reference the canonical dicts fromdeprecation.py.Impact
modifyassignments or in query expressions now get a deprecation warning and correct behaviour, instead of silently operating on a non-existent field.hooks.py,modify.py, and any future call sites.6483.