ui: remove do_query to tighten input_select_objects - #6942
Conversation
There was a problem hiding this comment.
Pull request overview
grug see PR want fix interactive select bug in modify, and also kill do_query so each command do own query work. grug like less hidden helper, but grug see some new typing + prompt bugs that will make CI sad (mypy/ruff).
Changes:
- Remove shared
beets.ui.commands.utils.do_queryhelper and adjust commands/tests to query items/albums directly. - Fix
modifyconfirm-selection flow to useui.show_model_changesso chosen objects get applied right. - Tighten/adjust
ui.input_select_objectstyping and update command modules (move,remove,update,write,edit) to new flow.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| test/ui/commands/test_utils.py | Remove tests tied to deleted do_query. |
| test/ui/commands/test_update.py | Update tests for new update_items(items=...) API. |
| test/ui/commands/test_remove.py | Split tests between remove_items and new remove_albums. |
| test/ui/commands/test_move.py | Update tests for move_items vs move_albums APIs and dest encoding. |
| docs/changelog.rst | Document modify interactive select bug fix. |
| beetsplug/edit.py | Stop using do_query; query items/albums directly. |
| beets/ui/commands/write.py | Stop using do_query; iterate lib.items(query). |
| beets/ui/commands/utils.py | Delete do_query helper module. |
| beets/ui/commands/update.py | Refactor update_items to accept explicit items iterable; query done in update_func. |
| beets/ui/commands/remove.py | Refactor into remove_objects + remove_items/remove_albums. |
| beets/ui/commands/move.py | Refactor into move_objects + move_items/move_albums, remove do_query. |
| beets/ui/commands/modify.py | Refactor into modify_objects + modify_items/modify_albums; fix selection apply bug. |
| beets/ui/init.py | Narrow (then adjust) typing for input_select_objects return/args. |
Suppressed comments (4)
beets/ui/commands/remove.py:37
- grug see prompt text use len(objs) for item count. when objs be albums, count wrong. grug say remove count so prompt not lie.
else:
fmt = ""
prompt = "Really remove from the library?"
prompt_all = (
f"Really remove {len(objs)} item{suffix} from the library?"
beets/ui/commands/move.py:79
- grug see num_unmoved math always zero: num_objs == len(objs), so num_unmoved always 0. message code dead, confuse future grug.
num_objs = len(objs)
num_unmoved = num_objs - len(objs)
# Report unmoved files that match the query.
unmoved_msg = ""
if num_unmoved > 0:
beets/ui/commands/update.py:29
- grug see update_items fields arg can be None (opts.fields default None) but type say list[str]. mypy will bonk. make it Optional.
items: Iterable[Item],
move: bool,
pretend: bool,
fields: list[str],
exclude_fields: list[str] | None = None,
beets/ui/commands/modify.py:127
- grug see same doc string typo again: "pairse" -> "pairs".
"""Modifies matching items according to user-specified assignments and
deletions.
`mods` is a dictionary of field and value pairse indicating
assignments. `dels` is a list of fields to be deleted.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
0fdce0b to
aaf058b
Compare
aaf058b to
65cc028
Compare
f5a949f to
50ab88b
Compare
65cc028 to
60bfc97
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 25 changed files in this pull request and generated no new comments.
Suppressed comments (4)
beets/ui/commands/remove.py:42
- grug see remove prompt text wrong: say "item" even when removing albums, no plural "items", and has trailing "?" so
input_select_objectsmake "??". grug say build noun + plural, and do not include '?' in prompt strings.
fmt = ""
prompt = "Really remove from the library?"
prompt_all = (
f"Really remove {len(objs)} item{album_str} from the library?"
)
beets/ui/commands/move.py:80
- grug see
num_unmovedmath always make 0 (len(objs) - len(objs)). log say "already in place" count but never true. grug say either pass real unmoved count from caller, or do not try compute here.
num_objs = len(objs)
num_unmoved = num_objs - len(objs)
beets/ui/commands/remove.py:21
- grug see type here too loose:
remove_objectstakeCallable[[str, AlbumOrItem], None]but callers passfmt_item(Item only) orfmt_album(Album only). static type checker can yell. grug say makeremove_objectsgeneric over same T for objs and formatter.
This issue also appears on line 38 of the same file.
def remove_objects(
objs: Sequence[AlbumOrItem],
fmt_obj: Callable[[str, AlbumOrItem], None],
file_count: int,
album_str: str,
beets/ui/commands/update.py:28
- grug see
update_itemssayfields: list[str], but code + option parser pass None when no--field. type lie make checker sad. grug say annotate as optional.
fields: list[str],
60bfc97 to
6913b74
Compare
bff3c92 to
f03dbdf
Compare
6913b74 to
3064c95
Compare
f03dbdf to
65aa846
Compare
3064c95 to
812abbc
Compare
65aa846 to
7cd0ef5
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## type-beets-core #6942 +/- ##
==================================================
Coverage ? 76.02%
==================================================
Files ? 164
Lines ? 21560
Branches ? 3334
==================================================
Hits ? 16390
Misses ? 4380
Partials ? 790
🚀 New features to boost your workflow:
|
812abbc to
ce88be5
Compare
7cd0ef5 to
ca8a30e
Compare
ce88be5 to
66aa044
Compare
ca8a30e to
ab123e2
Compare
66aa044 to
d3ca372
Compare
ab123e2 to
805c761
Compare
d3ca372 to
13e8ec8
Compare
805c761 to
b1e0df9
Compare
13e8ec8 to
2d687de
Compare
b1e0df9 to
20d913a
Compare
do_query to tighten input_select_objectsdo_query to tighten input_select_objects
2d687de to
b62798c
Compare
20d913a to
2bc3051
Compare
This allows to define a proper return type for input_select_objects.
b62798c to
6dbbc76
Compare
2bc3051 to
725ef3e
Compare
Part of #6924.
Purpose
modifyso chosen objects are actually applied correctly.do_queryhelper and letting each command handleitemandalbumqueries directly.Architecture
beets.ui.commands.utils.do_queryis removed.modify,move,remove,update,write, andedit.item/albumoperations instead of a generic query abstraction.ui.input_select_objectsnow has a narrower, model-specific type signature based onAlbumOrItem, which makes its return value clearer and easier to use safely.High-level impact
modifyinteractive select mode.itemvsalbumhandling.Tests and docs
move,remove, andupdate.docs/changelog.rstdocuments themodifyselection bug fix.