From afe97cf31eb4ed9297c1ba37c85727221758c905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0ar=C5=ABnas=20Nejus?= Date: Tue, 8 Jul 2025 11:27:46 +0100 Subject: [PATCH] Do not assign args to query --- beets/ui/__init__.py | 9 ++------- beetsplug/bareasc.py | 5 ++--- beetsplug/bpsync.py | 5 ++--- beetsplug/edit.py | 3 +-- beetsplug/limit.py | 5 ++--- beetsplug/mbsync.py | 5 ++--- beetsplug/metasync/__init__.py | 3 +-- beetsplug/random.py | 5 ++--- 8 files changed, 14 insertions(+), 26 deletions(-) diff --git a/beets/ui/__init__.py b/beets/ui/__init__.py index 4f4236ff9..74dee550c 100644 --- a/beets/ui/__init__.py +++ b/beets/ui/__init__.py @@ -1293,14 +1293,9 @@ class CommonOptionsParser(optparse.OptionParser): setattr(parser.values, option.dest, True) # Use the explicitly specified format, or the string from the option. - if fmt: - value = fmt - elif value: - (value,) = [value] - else: - value = "" - + value = fmt or value or "" parser.values.format = value + if target: config[target._format_config_key].set(value) else: diff --git a/beetsplug/bareasc.py b/beetsplug/bareasc.py index ed1057b20..d2852bb1d 100644 --- a/beetsplug/bareasc.py +++ b/beetsplug/bareasc.py @@ -83,14 +83,13 @@ class BareascPlugin(BeetsPlugin): def unidecode_list(self, lib, opts, args): """Emulate normal 'list' command but with unidecode output.""" - query = args album = opts.album # Copied from commands.py - list_items if album: - for album in lib.albums(query): + for album in lib.albums(args): bare = unidecode(str(album)) print_(bare) else: - for item in lib.items(query): + for item in lib.items(args): bare = unidecode(str(item)) print_(bare) diff --git a/beetsplug/bpsync.py b/beetsplug/bpsync.py index 656f30425..ccd781b28 100644 --- a/beetsplug/bpsync.py +++ b/beetsplug/bpsync.py @@ -65,10 +65,9 @@ class BPSyncPlugin(BeetsPlugin): move = ui.should_move(opts.move) pretend = opts.pretend write = ui.should_write(opts.write) - query = args - self.singletons(lib, query, move, pretend, write) - self.albums(lib, query, move, pretend, write) + self.singletons(lib, args, move, pretend, write) + self.albums(lib, args, move, pretend, write) def singletons(self, lib, query, move, pretend, write): """Retrieve and apply info from the autotagger for items matched by diff --git a/beetsplug/edit.py b/beetsplug/edit.py index e0c6509c8..52387c314 100644 --- a/beetsplug/edit.py +++ b/beetsplug/edit.py @@ -180,8 +180,7 @@ class EditPlugin(plugins.BeetsPlugin): def _edit_command(self, lib, opts, args): """The CLI command function for the `beet edit` command.""" # Get the objects to edit. - query = args - items, albums = _do_query(lib, query, opts.album, False) + items, albums = _do_query(lib, args, opts.album, False) objs = albums if opts.album else items if not objs: ui.print_("Nothing to edit.") diff --git a/beetsplug/limit.py b/beetsplug/limit.py index 2d5a30f24..aae99a717 100644 --- a/beetsplug/limit.py +++ b/beetsplug/limit.py @@ -36,11 +36,10 @@ def lslimit(lib, opts, args): if (opts.head or opts.tail or 0) < 0: raise ValueError("Limit value must be non-negative") - query = args if opts.album: - objs = lib.albums(query) + objs = lib.albums(args) else: - objs = lib.items(query) + objs = lib.items(args) if opts.head is not None: objs = islice(objs, opts.head) diff --git a/beetsplug/mbsync.py b/beetsplug/mbsync.py index 36e8cbd47..d38b25e9f 100644 --- a/beetsplug/mbsync.py +++ b/beetsplug/mbsync.py @@ -63,10 +63,9 @@ class MBSyncPlugin(BeetsPlugin): move = ui.should_move(opts.move) pretend = opts.pretend write = ui.should_write(opts.write) - query = args - self.singletons(lib, query, move, pretend, write) - self.albums(lib, query, move, pretend, write) + self.singletons(lib, args, move, pretend, write) + self.albums(lib, args, move, pretend, write) def singletons(self, lib, query, move, pretend, write): """Retrieve and apply info from the autotagger for items matched by diff --git a/beetsplug/metasync/__init__.py b/beetsplug/metasync/__init__.py index 4c7aac1c0..f99e820b5 100644 --- a/beetsplug/metasync/__init__.py +++ b/beetsplug/metasync/__init__.py @@ -97,7 +97,6 @@ class MetaSyncPlugin(BeetsPlugin): def func(self, lib, opts, args): """Command handler for the metasync function.""" pretend = opts.pretend - query = args sources = [] for source in opts.sources: @@ -106,7 +105,7 @@ class MetaSyncPlugin(BeetsPlugin): sources = sources or self.config["source"].as_str_seq() meta_source_instances = {} - items = lib.items(query) + items = lib.items(args) # Avoid needlessly instantiating meta sources (can be expensive) if not items: diff --git a/beetsplug/random.py b/beetsplug/random.py index 55a9f40e5..c791af414 100644 --- a/beetsplug/random.py +++ b/beetsplug/random.py @@ -22,11 +22,10 @@ from beets.ui import Subcommand, print_ def random_func(lib, opts, args): """Select some random items or albums and print the results.""" # Fetch all the objects matching the query into a list. - query = args if opts.album: - objs = list(lib.albums(query)) + objs = list(lib.albums(args)) else: - objs = list(lib.items(query)) + objs = list(lib.items(args)) # Print a random subset. objs = random_objs(