Lastgenre: Split last.fm fetching and file loading to separate files#6368
Lastgenre: Split last.fm fetching and file loading to separate files#6368
Conversation
9ff6150 to
0f131b5
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #6368 +/- ##
==========================================
+ Coverage 69.32% 69.41% +0.08%
==========================================
Files 141 143 +2
Lines 18786 18819 +33
Branches 3060 3063 +3
==========================================
+ Hits 13024 13063 +39
+ Misses 5117 5110 -7
- Partials 645 646 +1
🚀 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 |
fd7f4b1 to
9a3a6ba
Compare
|
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. |
dc2d778 to
d0efc62
Compare
d0efc62 to
a540a81
Compare
998f9a6 to
751d5d1
Compare
bca897c to
74608d2
Compare
d16b81c to
b740c85
Compare
and tunelog helper to a utils module since we will need it everywhere.
b740c85 to
d70d8e9
Compare
d70d8e9 to
42b0d45
Compare
Description
flatten_tree()→DataFileLoader(tree processing)find_parents()→LastGenrePlugin(genre canonicalization)New modules
utils.py- Shared utilities withmake_tunelog()factory for bound logging functionsclient.py- Last.fm API client (LastFmClient) extracted from main pluginloaders.py- Data file loader (DataFileLoader) withfrom_config()factory patterntypes.py- Named types for parsed whitelist and canonicalization tree(prepare for future datafile formats)No functional changes - pure refactoring to improve structure.
To Do
Documentation.