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 #6550 +/- ##
==========================================
+ Coverage 71.19% 71.78% +0.59%
==========================================
Files 150 156 +6
Lines 19175 20176 +1001
Branches 3084 3214 +130
==========================================
+ Hits 13651 14484 +833
- Misses 4864 5006 +142
- Partials 660 686 +26
🚀 New features to boost your workflow:
|
09e61e7 to
bb7c0ba
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
grug see PR want one place for field -> type mapping, so Album and Item no drift.
Changes:
- move Album/Item fixed field list to
_field_namessets, and derive_fieldsfrom shared registry - update media-field set logic to use
_field_names, and deriveAlbum.item_keysfrom field set math - change coverage task to use
--cov=.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pyproject.toml | change pytest-cov source selection for coverage runs |
| beets/library/models.py | replace per-model _fields dicts with _field_names + derived _fields, adjust related logic |
e581fc1 to
e3315bd
Compare
semohr
requested changes
Apr 19, 2026
e3315bd to
ded00cf
Compare
ded00cf to
f2d324f
Compare
I found that beetsplug/musicbrainz.py does not appear under https://app.codecov.io/gh/beetbox/beets/tree/master/beetsplug. Setting coverage source as repo root should fix this.
f2d324f to
e2e8e80
Compare
semohr
approved these changes
Apr 19, 2026
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.
Centralise Field Type Definitions
Summary
This PR eliminates duplicated field-to-type mappings across
AlbumandItemmodel classes. Previously, each model class maintained its own_fields: dict[str, types.Type]— a verbose, hand-written dictionary that encoded both which fields exist and what type each one has. This duplication made it easy for the two definitions to drift out of sync.Architecture Change
Before: Each model class owned a full inline
_fieldsdict mapping field names to type instances.After: Field names are declared as a
set[str], and the type mapping is derived lazily from a single centralisedTYPE_BY_FIELDregistry inbeets.dbcore.fields.This creates a clean separation of concerns:
_field_names)dbcore.fields.TYPE_BY_FIELDKey Impacts
dbcore.fieldsItem._fieldsAlbum._field_namesAlbum.item_keys_field_names - {"artpath", "id"}_media_fields/_media_tag_fields_fields.keys()_field_namesdirectly--cov=beets --cov=beetsplug--cov=.(fixes missingbeetsplug/musicbrainz.py)Risk Areas to Review
TYPE_BY_FIELDcompleteness: all field names in_field_namesmust have a corresponding entry in the registry — a missing key will raise at class definition time viacached_classproperty.Album.item_keyssemantics: changed fromlisttosetand is now derived automatically. Any code that relied on ordering or specific list membership should be checked.Item._field_namesinheritance expression:Album._field_names - {"artpath"} | {...}— operator precedence here is(Album._field_names - {"artpath"}) | {...}, which is the intended behaviour, but worth a close read.