Lastgenre: Cleanup existing genres#6317
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 69.39% 69.39% -0.01%
==========================================
Files 141 141
Lines 18811 18816 +5
Branches 3066 3068 +2
==========================================
+ Hits 13054 13057 +3
- Misses 5111 5112 +1
- Partials 646 647 +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 |
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"]:e1791e4 to
149cb41
Compare
acaf88a to
ef58634
Compare
Thanks. Nothing to do here. LGTM but I would like to wait for the test thing yes. Best if I ping you once that is done so you don't have to keep doing boring rebase work :-) Thanks!!! |
Fixes a bug in the lastgenre plugin, where test state bled into the following fixtures. Each plugin has a view to the global persisted beets.config field. As a result, config variables that aren't explicitly overwritten are persisted in that global config view. This commit exposes the lastgenre default config as a static method and uses that default config to reset the state in between fixture calls. There were 3 tests that depended on `count: 10` being set on previous test fixtures, which I adjusted accordingly. Discovered and discussed in #6317 , see #6317 (comment)
ef58634 to
92b9392
Compare
49c62b0 to
8124de7
Compare
|
@JOJ0 back to you! |
"keep + original, whitelist" is the log label we get now, right? when running without --force we usually get "keep any, no-force" hmm,. let's review what the purpose of this logging label was as its "kind of" documented in the docstring of _get_genre In the fallback stage we have a pretty similar logic and these are the possible outcomes: original fallback This all is very confusing to me already. Haha. Hmm I'm just thinking out lout here trying to justify that the label we get now "keep + original, whitelist" is good enough. Or would it make more sense if we pass which is also kind of weird because it says: we keep original genres and combine them with original cleaned up genres. Maybe the Help me think here @Nukesor and sorry for another "brainstorming" delay! We are almost done here! Thanks for your patience! One thing I do like very much as this feature turned out: In the beginning I thought we should have this option as |
|
Haha, yep. I was pretty confused when picking the label as well 😅. It's a bit obscure.
Maybe a
Yep, I agree :D |
0b25c83 to
f5e89e5
Compare
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
f5e89e5 to
13fe82f
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