Skip to content

lastgenre: Refactor _get_genre#6474

Draft
JOJ0 wants to merge 7 commits intolastgenre_aliasesfrom
lastgenre_refactor_get_genre
Draft

lastgenre: Refactor _get_genre#6474
JOJ0 wants to merge 7 commits intolastgenre_aliasesfrom
lastgenre_refactor_get_genre

Conversation

@JOJ0
Copy link
Copy Markdown
Member

@JOJ0 JOJ0 commented Mar 30, 2026

Description

The monolithic _get_genre method was broken down into the following private instance methods:

  • Core Helpers:
    • _try_resolve_stage: Handles the canonicalization and logging of genres for a specific stage.
    • _fallback_stage: Provides the configured fallback genre.
  • Lookup Stages:
    • _handle_existing_genres: Manages the initial check for pre-existing genres and the cleanup_existing logic.
    • _get_track_genre_stage: Fetches and resolves track-level genres.
    • _get_album_genre_stage: Fetches and resolves album-level genres.
    • _get_artist_genre_stage: Fetches and resolves artist-level genres, including multi-valued album artists and "Various Artists" logic.
    • _get_va_genre_stage: specifically handles the plurality logic for "Various Artists" albums.
  • Fallbacks:
    • _get_original_fallback: Handles the "keep_existing" logic that attempts to use/canonicalize originally present genres if no new ones are found.

To Do

  • Documentation
  • Changelog
  • Tests (_get_genre was already well covered and the signature of the method was kept)

@JOJ0 JOJ0 requested a review from a team as a code owner March 30, 2026 17:17
@github-actions
Copy link
Copy Markdown

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.

@JOJ0 JOJ0 changed the base branch from master to lastgenre_aliases March 30, 2026 17:20
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 30, 2026

Codecov Report

❌ Patch coverage is 65.26316% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.99%. Comparing base (f4b9436) to head (89cf4e5).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
beetsplug/lastgenre/__init__.py 65.26% 22 Missing and 11 partials ⚠️
Additional details and impacted files
@@                  Coverage Diff                  @@
##           lastgenre_aliases    #6474      +/-   ##
=====================================================
+ Coverage              69.96%   69.99%   +0.03%     
=====================================================
  Files                    146      146              
  Lines                  18642    18661      +19     
  Branches                3052     3054       +2     
=====================================================
+ Hits                   13042    13061      +19     
- Misses                  4957     4958       +1     
+ Partials                 643      642       -1     
Files with missing lines Coverage Δ
beetsplug/lastgenre/__init__.py 84.21% <65.26%> (+0.98%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JOJ0 JOJ0 marked this pull request as draft March 30, 2026 20:05
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.

1 participant