Lastgenre: Separate last.fm client; Centralize extra_debug logging; Group related methods #6368
Lastgenre: Separate last.fm client; Centralize extra_debug logging; Group related methods #6368
extra_debug logging; Group related methods #6368Conversation
9ff6150 to
0f131b5
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #6368 +/- ##
==========================================
+ Coverage 69.68% 69.69% +0.01%
==========================================
Files 144 145 +1
Lines 18534 18541 +7
Branches 3028 3028
==========================================
+ Hits 12916 12923 +7
Misses 4982 4982
Partials 636 636
🚀 New features to boost your workflow:
|
b1e9732 to
22de6ee
Compare
09fac2f to
cc5c589
Compare
c1cc917 to
943d6b1
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors the lastgenre plugin into a modular structure by extracting Last.fm API client, file loaders, and utilities into separate modules. The refactoring maintains all existing functionality while improving code organization and preparing for future enhancements.
Changes:
- Created four new modules (utils.py, types.py, loaders.py, client.py) to separate concerns
- Applied factory pattern (
from_config()) for configuration-based initialization, consistent with other plugins - Moved static helper methods to their logical owners (flatten_tree → DataFileLoader, find_parents → LastGenrePlugin)
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| beetsplug/lastgenre/utils.py | New module with shared utilities including make_tunelog() factory for bound logging |
| beetsplug/lastgenre/types.py | New module defining type aliases for Whitelist, CanonTree, and GenreCache |
| beetsplug/lastgenre/loaders.py | New module with DataFileLoader class for loading whitelist and canonicalization tree files |
| beetsplug/lastgenre/client.py | New module with LastFmClient class extracted from main plugin for Last.fm API interactions |
| beetsplug/lastgenre/init.py | Refactored main plugin to use new modular structure, removing ~180 lines of code |
| test/plugins/test_lastgenre.py | Updated tests to reflect new module structure (client methods now accessed via plugin.client) |
| docs/changelog.rst | Added changelog entries documenting the refactoring and separator option removal |
a3100b6 to
cd0dc9b
Compare
extra_debug logging; Group related methods
|
Hi @snejus we had a chat around this refactor. It is now ready for a review. One thing we did not discuss is that I grouped all the canonicalization helpers together. In my first version I had them put into the classes together with the methods that were in there already and made them staticmethods. Now I like this new approach better. Have a look at c21c207, all pure functions that manipulate a Also note that I only put the |
471a673 to
c3d20c2
Compare
8e956ae to
3e1a22a
Compare
snejus
left a comment
There was a problem hiding this comment.
Looks good, just one question regarding making extra_debug a method on BeetsLogger, so that one can do self.log.extra_debug(...).
3e1a22a to
747f9ed
Compare
f7aced7 to
4431aeb
Compare
Description
tuneloghelper available asextra_debuginlogger.py- now usable everywhere in beets.New modules
client.py- Last.fm API client (LastFmClient) extracted from main pluginNo functional changes - pure refactoring to improve structure.
To Do
Documentation.