Skip to content

Swap Discogs genres and styles#6478

Open
snejus wants to merge 2 commits intomasterfrom
discogs-swap-genres-style
Open

Swap Discogs genres and styles#6478
snejus wants to merge 2 commits intomasterfrom
discogs-swap-genres-style

Conversation

@snejus
Copy link
Copy Markdown
Member

@snejus snejus commented Mar 31, 2026

discogs: Swap genre and style field mapping

Fixes #6390

Fixes the semantic mismatch between Discogs' taxonomy and beets' fields. In Discogs, genres are broad (e.g. "Electronic") and styles are specific (e.g. "Techno"). Previously, beets stored them the wrong way around.

What changed

In get_album_info, the source fields are swapped:

  • genres (beets) now reads from Discogs styles — the specific values
  • style (beets) now reads from Discogs genres — the broader values

The append_style_genre config option retains its original intent: append broader style values to genres when enabled. Only the data source for each field changed, not the logic.

@snejus snejus requested a review from a team as a code owner March 31, 2026 00:31
Copilot AI review requested due to automatic review settings March 31, 2026 00:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

PR swap Discogs genre/style mapping so beets fields match Discogs meaning: Discogs genres are broad, Discogs styles are specific.

Changes:

  • In Discogs plugin, read beets genres from Discogs styles, and beets style from Discogs genres.
  • Update Discogs plugin tests to cover the swapped mapping.
  • Update Discogs plugin docs + changelog entry for new mapping.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
beetsplug/discogs/__init__.py Swap Discogs genres/styles inputs when building AlbumInfo.style and AlbumInfo.genres.
test/plugins/test_discogs.py Adjust release fixture + assertions for swapped mapping; rename one test.
docs/plugins/discogs.rst Update append_style_genre + separator docs to describe new semantics.
docs/changelog.rst Add changelog entry describing the Discogs mapping change.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.01%. Comparing base (74007ec) to head (69af3cc).
⚠️ Report is 2 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6478   +/-   ##
=======================================
  Coverage   70.01%   70.01%           
=======================================
  Files         146      146           
  Lines       18505    18505           
  Branches     3010     3010           
=======================================
  Hits        12957    12957           
  Misses       4920     4920           
  Partials      628      628           
Files with missing lines Coverage Δ
beetsplug/discogs/__init__.py 67.28% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment on lines +379 to 384
def test_append_style_to_genre_no_styles(self):
"""Test nothing appended to genre if style is empty"""
config["discogs"]["append_style_genre"] = True
release = self._make_release_from_positions(["1", "2"])
release.data["styles"] = []
release.data["genres"] = []

Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grug see docstring talk about "style is empty" but test now empties release.data["genres"] (since beets style reads Discogs genres). please align names (either change wording or change which field emptied) so test not confuse.

Copilot uses AI. Check for mistakes.
Comment on lines +134 to +135
How to join the broader Discogs style values into the ``style`` field
string.
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grug see separator docs still say "broader Discogs style values" but style field now built from Discogs genres (broader). please update sentence to say Discogs genre values (or just values stored in style).

Suggested change
How to join the broader Discogs style values into the ``style`` field
string.
How to join the Discogs genre values stored in the ``style`` field into a
single string.

Copilot uses AI. Check for mistakes.
Comment on lines +406 to +407
styles: list[str] = result.data.get("genres") or []
genres: list[str] = result.data.get("styles") or []
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grug see genres and styles variables point at lists inside result.data. genres.extend(styles) will mutate result.data["styles"] in-place when option on. that make weird side effect and can duplicate if get_album_info called twice on same Release. safer: copy lists (ex list(...)) before extend.

Suggested change
styles: list[str] = result.data.get("genres") or []
genres: list[str] = result.data.get("styles") or []
raw_styles = result.data.get("genres") or []
raw_genres = result.data.get("styles") or []
styles: list[str] = list(raw_styles)
genres: list[str] = list(raw_genres)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discogs: consider styles as genre

2 participants