lastgenre: Refactor _get_genre - #6474
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❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6474 +/- ##
==========================================
+ Coverage 76.06% 76.11% +0.04%
==========================================
Files 163 163
Lines 21146 21151 +5
Branches 3334 3334
==========================================
+ Hits 16085 16099 +14
+ Misses 4273 4264 -9
Partials 788 788
🚀 New features to boost your workflow:
|
e2f60a5 to
47ae4ab
Compare
|
@semohr @snejus @henry-oberholtzer @Serene-Arc anyone care to review a no-op refactor-only PR? :-) Thanks :-) |
929b3ea to
47f6c96
Compare
|
Thanks @snejus that was great feedback! 👍 I think I addressed all of it. |
ae56202 to
ceb2d5c
Compare
cf8cb27 to
c48c2e7
Compare
c48c2e7 to
dae33c0
Compare
- fallback as cached property - Leave force check in main get_genre() - Leave fall back handling in get_genre()
Note that the artist stage is slightly different and GenresWithLabel does not fit there.
dae33c0 to
87633a8
Compare
|
Hi @snejus, thanks for the approval. Did two more tiny things: Fixed mypy errors, accidentally applied |
Description
The monolithic
_get_genremethod was broken down into several private instance methods and refactored for readability. The contract is kept and is already well tested (test_get_genre)Core Helpers - were moved from within
_get_genreto a reusable instance method and acached_property:_try_resolve_stage: Handles the canonicalization and logging of genres for a specific stage.fallback: Provides the configured fallback genre. Is used as a last resort in_try_resolve_existing_genresand when_get_genrecouldn't find any genre in any stage at all.Lookup Stages - some were complex enough to deserve their own instance method for readability, some stay inline in
_get_genre:_try_resolve_existing_genres: Manages the initial check for pre-existing genres and thecleanup_existinglogic whenforceis disabled._fetch_artist_stage: Fetches and resolves artist-level genres, including multi-valued album artists and "Various Artists" logic._fetch_va_genres: specifically handles the plurality logic for "Various Artists" albums.Fallbacks:
_try_resolve_original_fallback: Handles the "keep_existing" logic that attempts to use/canonicalize originally present genres if no new ones are found.Make sure to also look at subsequent PR's:
To Do
DocumentationTests(_get_genre was already well covered and the signature of the method was kept)