Skip to content

Commit 1838482

Browse files
committed
Keep missing multi-value fields as None instead of empty list
1 parent 0f7bce1 commit 1838482

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

beets/autotag/hooks.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ def __init__(
9797
self.artist = artist
9898
self.artist_credit = artist_credit
9999
self.artist_id = artist_id
100-
self.artists = artists or []
101-
self.artists_credit = artists_credit or []
102-
self.artists_ids = artists_ids or []
100+
self.artists = artists
101+
self.artists_credit = artists_credit
102+
self.artists_ids = artists_ids
103103
self.artist_sort = artist_sort
104-
self.artists_sort = artists_sort or []
104+
self.artists_sort = artists_sort
105105
self.data_source = data_source
106106
self.data_url = data_url
107107
self.genre = None
108-
self.genres = genres or []
108+
self.genres = genres
109109
self.media = media
110110
self.update(kwargs)
111111

@@ -160,7 +160,7 @@ def __init__(
160160
self.albumdisambig = albumdisambig
161161
self.albumstatus = albumstatus
162162
self.albumtype = albumtype
163-
self.albumtypes = albumtypes or []
163+
self.albumtypes = albumtypes
164164
self.asin = asin
165165
self.barcode = barcode
166166
self.catalognum = catalognum

docs/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ Bug fixes
4444
- :doc:`plugins/zero`: When the ``omit_single_disc`` option is set,
4545
``disctotal`` is zeroed alongside ``disc``.
4646
- :doc:`plugins/fetchart`: Prevent deletion of configured fallback cover art
47+
- In autotagging, initialise empty multi-valued fields with ``None`` instead of
48+
empty list, which caused beets to overwrite existing metadata with empty list
49+
values instead of leaving them unchanged. :bug:`6403`
4750

4851
For plugin developers
4952
~~~~~~~~~~~~~~~~~~~~~

test/plugins/test_musicbrainz.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ def test_no_genres(self):
539539
config["musicbrainz"]["genres"] = False
540540
release = self._make_release()
541541
d = self.mb.album_info(release)
542-
assert d.genres == []
542+
assert d.genres is None
543543

544544
def test_ignored_media(self):
545545
config["match"]["ignored_media"] = ["IGNORED1", "IGNORED2"]

test/test_autotag.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ def setUp(self):
229229
},
230230
]
231231

232-
@pytest.mark.xfail(reason="Album genres are not applied to tracks")
233232
def test_autotag_items(self):
234233
self._apply()
235234

0 commit comments

Comments
 (0)