Skip to content

Commit 05430f3

Browse files
committed
Move PromptChoice to beets.util module
And update imports that have been raising the deprecation warning.
1 parent dd72704 commit 05430f3

File tree

8 files changed

+23
-26
lines changed

8 files changed

+23
-26
lines changed

beets/ui/commands/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def __getattr__(name: str):
3939
__name__,
4040
{
4141
"TerminalImportSession": "beets.ui.commands.import_.session",
42-
"PromptChoice": "beets.ui.commands.import_.session",
42+
"PromptChoice": "beets.util",
4343
},
4444
name,
4545
)

beets/ui/commands/import_/session.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
from collections import Counter
22
from itertools import chain
3-
from typing import Any, NamedTuple
43

54
from beets import autotag, config, importer, logging, plugins, ui
65
from beets.autotag import Recommendation
7-
from beets.util import displayable_path
6+
from beets.util import PromptChoice, displayable_path
87
from beets.util.units import human_bytes, human_seconds_short
98

109
from .display import (
@@ -368,12 +367,6 @@ def _summary_judgment(rec):
368367
return action
369368

370369

371-
class PromptChoice(NamedTuple):
372-
short: str
373-
long: str
374-
callback: Any
375-
376-
377370
def choose_candidate(
378371
candidates,
379372
singleton,

beets/util/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ class MoveOperation(Enum):
167167
REFLINK_AUTO = 5
168168

169169

170+
class PromptChoice(NamedTuple):
171+
short: str
172+
long: str
173+
callback: Any
174+
175+
170176
def normpath(path: PathLike) -> bytes:
171177
"""Provide the canonical form of the path suitable for storing in
172178
the database.

beetsplug/edit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
from beets import plugins, ui, util
2626
from beets.dbcore import types
2727
from beets.importer import Action
28-
from beets.ui.commands.import_.session import PromptChoice
2928
from beets.ui.commands.utils import do_query
29+
from beets.util import PromptChoice
3030

3131
# These "safe" types can avoid the format/parse cycle that most fields go
3232
# through: they are safe to edit with native YAML types.

beetsplug/mbsubmit.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
from beets import ui
2727
from beets.autotag import Recommendation
2828
from beets.plugins import BeetsPlugin
29-
from beets.ui.commands import PromptChoice
30-
from beets.util import displayable_path
29+
from beets.util import PromptChoice, displayable_path
3130
from beetsplug.info import print_data
3231

3332

beetsplug/play.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
from beets import config, ui, util
2222
from beets.plugins import BeetsPlugin
2323
from beets.ui import Subcommand
24-
from beets.ui.commands import PromptChoice
25-
from beets.util import get_temp_filename
24+
from beets.util import PromptChoice, get_temp_filename
2625

2726
# Indicate where arguments should be inserted into the command string.
2827
# If this is missing, they're placed at the end.

docs/dev/plugins/other/prompts.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ shall expose to the user:
1313
.. code-block:: python
1414
1515
from beets.plugins import BeetsPlugin
16-
from beets.ui.commands import PromptChoice
16+
from beets.util import PromptChoice
1717
1818
1919
class ExamplePlugin(BeetsPlugin):

test/test_plugins.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
PluginTestCase,
4242
TerminalImportMixin,
4343
)
44-
from beets.util import displayable_path, syspath
44+
from beets.util import PromptChoice, displayable_path, syspath
4545

4646

4747
class TestPluginRegistration(PluginTestCase):
@@ -292,8 +292,8 @@ def __init__(self):
292292

293293
def return_choices(self, session, task):
294294
return [
295-
ui.commands.PromptChoice("f", "Foo", None),
296-
ui.commands.PromptChoice("r", "baR", None),
295+
PromptChoice("f", "Foo", None),
296+
PromptChoice("r", "baR", None),
297297
]
298298

299299
self.register_plugin(DummyPlugin)
@@ -328,8 +328,8 @@ def __init__(self):
328328

329329
def return_choices(self, session, task):
330330
return [
331-
ui.commands.PromptChoice("f", "Foo", None),
332-
ui.commands.PromptChoice("r", "baR", None),
331+
PromptChoice("f", "Foo", None),
332+
PromptChoice("r", "baR", None),
333333
]
334334

335335
self.register_plugin(DummyPlugin)
@@ -363,10 +363,10 @@ def __init__(self):
363363

364364
def return_choices(self, session, task):
365365
return [
366-
ui.commands.PromptChoice("a", "A foo", None), # dupe
367-
ui.commands.PromptChoice("z", "baZ", None), # ok
368-
ui.commands.PromptChoice("z", "Zupe", None), # dupe
369-
ui.commands.PromptChoice("z", "Zoo", None),
366+
PromptChoice("a", "A foo", None), # dupe
367+
PromptChoice("z", "baZ", None), # ok
368+
PromptChoice("z", "Zupe", None), # dupe
369+
PromptChoice("z", "Zoo", None),
370370
] # dupe
371371

372372
self.register_plugin(DummyPlugin)
@@ -399,7 +399,7 @@ def __init__(self):
399399
)
400400

401401
def return_choices(self, session, task):
402-
return [ui.commands.PromptChoice("f", "Foo", self.foo)]
402+
return [PromptChoice("f", "Foo", self.foo)]
403403

404404
def foo(self, session, task):
405405
pass
@@ -441,7 +441,7 @@ def __init__(self):
441441
)
442442

443443
def return_choices(self, session, task):
444-
return [ui.commands.PromptChoice("f", "Foo", self.foo)]
444+
return [PromptChoice("f", "Foo", self.foo)]
445445

446446
def foo(self, session, task):
447447
return Action.SKIP

0 commit comments

Comments
 (0)