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. |
4296305 to
64a9c41
Compare
There was a problem hiding this comment.
Pull request overview
This PR implements a new canonicalize_existing configuration flag for the lastgenre plugin to enable whitelist canonicalization of existing genres when force: no, canonical: yes, and whitelist: yes are set.
Changes:
- Adds a new
canonicalize_existingboolean configuration option with a default value ofFalse - Updates the genre resolution logic to canonicalize existing genres before returning them when the new flag is enabled
- Adds documentation explaining the new flag's behavior and requirements
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| beetsplug/lastgenre/init.py | Adds the canonicalize_existing config option and implements canonicalization logic for existing genres |
| docs/plugins/lastgenre.rst | Documents the new canonicalize_existing configuration option |
| docs/changelog.rst | Adds changelog entry for the new feature |
| test/plugins/test_lastgenre.py | Adds test case to verify canonicalization of existing genres |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6317 +/- ##
=======================================
Coverage 68.96% 68.96%
=======================================
Files 140 140
Lines 18685 18693 +8
Branches 3056 3058 +2
=======================================
+ Hits 12886 12892 +6
- Misses 5155 5156 +1
- Partials 644 645 +1
🚀 New features to boost your workflow:
|
1c99cf1 to
c796161
Compare
c796161 to
c5eb470
Compare
|
Hm interesting feature and useful, but I'm not sure if this should maybe be called something containing the word "cleanup". It might even include whitelist filtering without canonicalization too. I see it as a "cleanup existing only" kind of functionality. And are you sure this can't be included in the force branch somehow? We are moving away from force:no being what one would expect from it. let's brainstorm some more here please |
|
@Nukesor I adjusted my wording above slightly. I think it was weird. Maybe still is... |
|
I didn't read your first response, but the edited doesn't seem weird at all :D
The force-branch already canonicalizes local genres (if
It's more of a "cleanup stuff from lastfm, but please also cleanup local stuff that isn't force-overwritten/merged" :D Regarding "cleanup", I would be up for it, although I think that canonicalization better conveys what actually happens. If we were to change the wording, we should do it for the whole plugin though.
Neat. How would that look like? |
Yes you are right, my bad, I didn't think it through. Still: We are introducing an option that allows the user / beets to manipulate something even though they said: DO NOT FORCE, that is why I want to be supercareful to make this most obvious and understandable.
You are right
I agree that it could be easier and we discussed it way back when Each way has it's strenghtes though, I agree, but still I don't want to change the usability concept now again. It's established and well documented (I hope!) now. What I'm trying to say with a cleanup option is something like this:
A shortform No better idea for option naming currently, please help me out! :-)
maybe make this shorter more concise help text... We should not restrict this no-force-cleanup to canonicalization only. |
|
Damn. I started writing an answer and then got sidetracked. Sorry for the long wait.
I see. In that context, Tbh. now that I know the planned changes, I'm perfectly fine with So just to double-check, regarding this PR my todos would be:
What other cleanup would be there to perform? The current impl does |
c5eb470 to
16d4df8
Compare
|
btw: The CI is complaining about docstring formatting. docstrfmt docs README_kr.rst CONTRIBUTING.rst CODE_OF_CONDUCT.rst README.rst
121 files was checked.I'm using |
Beets does not support 3.14 yet - use 3.13 instead and install the dependencies with |
beetsplug/lastgenre/__init__.py
Outdated
| # No fallback configured. | ||
| return None, "fallback unconfigured" | ||
|
|
||
| # Without force pre-populated tags are returned as-is. |
There was a problem hiding this comment.
please adjust this comment: without force and ...
There was a problem hiding this comment.
or maybe remove it here and extend the larger comment above, right after the condition to include a concise description right at the entry point of the if genres and force not true) branch
There was a problem hiding this comment.
I kept the split, but adjusted the wording to match the code flow
snejus
left a comment
There was a problem hiding this comment.
Nice work on this! One thought on the condition here - if the user has set cleanup_existing, they've already opted in, so silently doing nothing when whitelist or canonical aren't set seems like a footgun.
_try_resolve_stage already handles whether whitelist filtering or canonicalization applies based on its own config, so wouldn't the following be sufficient?
if self.config["cleanup_existing"]:
whitelist checking as mentioned in the inline comments. and in the future maybe normalizing genre names. eg. DnB -> Drum And Bass, and removing blacklisted genres. |
394a76a to
f5f6346
Compare
|
@JOJ0 @snejus I adjusted according your review :) The tests fail now however. From what I can see, this is an issue with the way configuration is handled in beets. Test state (specifically the config values) persist once set. It looks like each plugin has a view to the global persisted Should this be fixed in a specific way or should I just work around this? The tests can be "fixed" by adding a |
37b001a to
e1791e4
Compare
|
I went ahead and added a commit on top that exposes the default config as a static method and uses that default config to reset the state in between fixture calls. There were 5 tests that depended on Let me know what you think of that change :) |
|
Hey, thanks for your work on this @Nukesor ! One thing I'd like to see changed is it being untied from I'd much prefer another solution. What if running You added a section in the docs for the new option but I think you should probably also update the Handling pre-populated tags section and force's description and if we're going this route. |
|
Hey @Bergbok If I understood you correctly, IMO, that behavior would makes sense, if we were to have multiple subcommands that represent different "stages".
Right now, existing tags are also "cleaned up" in Is there a way to easily introduce subcommands to plugins? |
nice catch!!! would it be too much to ask if you could split out this test refactor/fix into a separate PR. We have so much lastgenre stuff in flight currently and it would be easier for us that way! thank you very much!! 🙏 |
e1791e4 to
149cb41
Compare
02d51c4 to
51db511
Compare
Fixes a bug in the lastgenre, where test state bled into the following fixtures. Each plugin has a view to the global persisted beets.config field. As a result, variables that aren't explicitly overwritten are persisted in that global config view. This commit exposes the default config as a static method and uses that default config to reset the state in between fixture calls. There were 5 tests that depended on count: 10 being set on previous test fixtures, which I adjusted accordingly.
Introduce a new lastgenre `cleanup_existing` flag. It handles the case where canonicalization is desired on existing tags. The new logic triggers if: - `force`: False - `cleanup_existing: True Depending on whether `whitelist: True` or `canonical: True`, the genres are then canonicalized and/or whitelisting is applied
51db511 to
40675ae
Compare
Description
Fixes #6305
Implements a new
cleanup_existingconfig flag. The added documentation should explain its behavior. If there're any unclarities, we need to adjust the docs :)To Do