Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6493 +/- ##
==========================================
+ Coverage 70.11% 70.16% +0.04%
==========================================
Files 147 147
Lines 18625 18638 +13
Branches 3038 3042 +4
==========================================
+ Hits 13059 13077 +18
+ Misses 4923 4921 -2
+ Partials 643 640 -3
🚀 New features to boost your workflow:
|
e87d6f4 to
481ed7c
Compare
481ed7c to
b32f220
Compare
There was a problem hiding this comment.
Pull request overview
PR add --quiet flag + quiet config for smartplaylist splupdate, to cut noisy output while still showing per-playlist match counts. Also tweak unknown-playlist error to be sorted + shell-quoted for easy copy/paste.
Changes:
- Add
--quietCLI flag +quietconfig key; suppress banner + per-item output in pretend mode. - Sort + POSIX shell-quote playlist names in “unknown playlist” error message.
- Add CLI test coverage for quiet pretend output + quoted error.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
beetsplug/smartplaylist.py |
Implement quiet behavior, quoted error formatting, and per-playlist match-count logging. |
test/plugins/test_smartplaylist.py |
Add regression tests for quoted error + quiet pretend output suppression. |
docs/plugins/smartplaylist.rst |
Document new quiet option + --quiet flag. |
docs/changelog.rst |
Note new quiet flag + improved unknown-playlist error formatting. |
beetsplug/smartplaylist.py
Outdated
| self.__apply_opts_to_config(opts) | ||
| self.update_playlists(lib, opts.pretend) | ||
| self.update_playlists(lib, opts.pretend, quiet) |
There was a problem hiding this comment.
grug see quiet config supposed work, but __apply_opts_to_config run after and will write opts default False into config when user not pass --quiet. then config quiet become False inside process, and later auto update (cli_exit) no longer quiet. grug suggest make --quiet option default None (like other beets commands) and only copy opts into config when value is not None / option explicitly set.
| self, lib: Library, pretend: bool = False, quiet: bool = False | ||
| ) -> None: |
There was a problem hiding this comment.
grug see update_playlists(..., quiet=False) take quiet param, but when plugin run auto mode it call update_playlists from cli_exit listener with no quiet arg. then new config option smartplaylist.quiet do nothing for auto updates. grug suggest inside update_playlists read config quiet when quiet param not explicitly set (ex: quiet is None), so config option work everywhere.
| self, lib: Library, pretend: bool = False, quiet: bool = False | |
| ) -> None: | |
| self, | |
| lib: Library, | |
| pretend: bool = False, | |
| quiet: bool | None = None, | |
| ) -> None: | |
| if quiet is None: | |
| quiet = self.config["quiet"].get(bool) |
beetsplug/smartplaylist.py
Outdated
| if item_uri not in m3us[m3u_name]: | ||
| m3us[m3u_name].append(PlaylistItem(item, item_uri)) | ||
| if pretend and self.config["pretend_paths"]: | ||
| if pretend and self.config["pretend_paths"] and not quiet: | ||
| print(displayable_path(item_uri)) | ||
| elif pretend: | ||
| elif pretend and not quiet: | ||
| print(item) | ||
| pretend_count += 1 | ||
| self._log.info("{}: {} items matched.", name, pretend_count) |
There was a problem hiding this comment.
grug see duplicate guard broken: m3us[m3u_name] is list of PlaylistItem, but code check if item_uri not in m3us[m3u_name] (bytes vs object) so always True. can write duplicate lines when item appear twice (ex item query + album_query), and pretend_count also count duplicates since increment happen even when not appended. grug suggest track uris in set (or compare against entry.uri) and only bump count when new entry actually added.
Add a --quiet flag to reduce splupdate output while keeping the matched-track counts visible, which helps when testing new queries in the config. In pretend mode: - suppress "Results for playlist ..." - suppress "Showing query results for X smart playlists..." - suppress the list of matching tracks, including --pretend-paths output - replace the final "Displayed results ..." message with a shorter "... playlists would be updated" summary When updating: - suppress "Creating playlist ..."
since we require handling of store_true cli options something for the `quiet`
which enhances code readability for future readers.
Deduplicate playlist output by URI instead of comparing bytes to PlaylistItem objects. Increment matched/pretend counts only when a new entry is actually added. This prevents duplicate lines when the same track is reached via multiple query paths.
|
|
||
| self.__apply_opts_to_config(opts) | ||
| self.update_playlists(lib, opts.pretend) | ||
| self.update_playlists(lib, opts.pretend, opts.quiet) |
There was a problem hiding this comment.
Would you mind using self.config["quiet"] in downstream functions instead?
Description
Adds a --quiet CLI flag and config option to the smartplaylist plugin.
The flag reduces splupdate output while keeping the matched-track counts visible, which most of all helps with the use-case of testing new queries in the config (for example - does the newly added smartplaylist's quersy match a decent amount of tracks or is it to narrow).
In pretend mode:
When updating:
The new behavior is tested in
test_splupdate_pretend_quiet_suppresses_bannerAdditional refactoring
__apply_opts_to_confighelper was improved to also properly handlestore_truevaluesTo Do