From b030ed4a9501bb2ab5136ee7bd3985babe4d5c70 Mon Sep 17 00:00:00 2001 From: Jade Meister Date: Wed, 12 Nov 2025 22:15:12 -0500 Subject: [PATCH] linting and formatting fixes --- beetsplug/musicbrainz.py | 7 ++++--- test/plugins/test_musicbrainz.py | 16 +++++++++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/beetsplug/musicbrainz.py b/beetsplug/musicbrainz.py index 978d90d94..e17609b54 100644 --- a/beetsplug/musicbrainz.py +++ b/beetsplug/musicbrainz.py @@ -516,8 +516,10 @@ class MusicBrainzPlugin(MetadataSourcePlugin): # If this recording includes a release list, attach album metadata so # recording-based matches still write album/album_id. - rel_list = recording.get("release-list") or recording.get("release_list") - if rel_list: + rel_list = recording.get("release-list") or recording.get( + "release_list" + ) + if rel_list and len(rel_list) > 0: # Pick the first release as a reasonable default. rel0 = rel_list[0] or {} # Handle both shapes: {'id','title',...} or {'release': {'id','title',...}} @@ -870,7 +872,6 @@ class MusicBrainzPlugin(MetadataSourcePlugin): # Fall back for test environments where get_recording_by_id is not mocked yield self.track_info(r) - def album_for_id( self, album_id: str ) -> beets.autotag.hooks.AlbumInfo | None: diff --git a/test/plugins/test_musicbrainz.py b/test/plugins/test_musicbrainz.py index 38e52bed9..2de151d42 100644 --- a/test/plugins/test_musicbrainz.py +++ b/test/plugins/test_musicbrainz.py @@ -990,8 +990,11 @@ class TestMusicBrainzPlugin(PluginMixin): plugin = "musicbrainz" mbid = "d2a6f856-b553-40a0-ac54-a321e8e2da99" - RECORDING = {"title": "foo", "id": "90b2fd02-19c8-42b8-8592-d62542604ce9", "length": 42} - + RECORDING = { + "title": "foo", + "id": "90b2fd02-19c8-42b8-8592-d62542604ce9", + "length": 42, + } @pytest.fixture def plugin_config(self): @@ -1042,7 +1045,9 @@ class TestMusicBrainzPlugin(PluginMixin): assert len(candidates) == 1 assert candidates[0].track_id == self.RECORDING["id"] - def test_item_candidates_includes_album_from_release_list(self, monkeypatch, mb): + def test_item_candidates_includes_album_from_release_list( + self, monkeypatch, mb + ): """Ensure that item_candidates now attaches album info when the recording includes a release-list.""" RECORDING_WITH_RELEASE = { "title": "Beautiful in White", @@ -1068,7 +1073,9 @@ class TestMusicBrainzPlugin(PluginMixin): lambda *_, **__: {"recording": RECORDING_WITH_RELEASE}, ) - candidates = list(mb.item_candidates(Item(), "Shane Filan", "Beautiful in White")) + candidates = list( + mb.item_candidates(Item(), "Shane Filan", "Beautiful in White") + ) # Ensure exactly one candidate was found assert len(candidates) == 1 @@ -1081,7 +1088,6 @@ class TestMusicBrainzPlugin(PluginMixin): assert candidate.album == "Love Always (Deluxe Edition)" assert candidate.album_id == "9ec75bce-60ac-41e9-82a5-3b71a982257d" - def test_candidates(self, monkeypatch, mb): monkeypatch.setattr( "musicbrainzngs.search_releases",