Skip to content

Commit 67f4d96

Browse files
committed
refactor(cli[utils]): Remove _validate_choices
1 parent ac155a4 commit 67f4d96

File tree

4 files changed

+1
-45
lines changed

4 files changed

+1
-45
lines changed

docs/api.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ If you need an internal API stabilized please [file an issue](https://github.com
4949
.. automethod:: tmuxp.cli.utils.get_config_dir
5050
```
5151

52-
```{eval-rst}
53-
.. automethod:: tmuxp.cli.utils._validate_choices
54-
```
55-
5652
```{eval-rst}
5753
.. automethod:: tmuxp.cli.import_config.get_teamocil_dir
5854
```

src/tmuxp/cli/load.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,6 @@ def load_workspace(
430430
)
431431
options = ["y", "n", "a"]
432432
choice = prompt_choices(msg, choices=options)
433-
# value_proc=_validate_choices(options))
434433

435434
if choice == "y":
436435
_load_attached(builder, detached)
@@ -450,7 +449,6 @@ def load_workspace(
450449
choice = prompt_choices(
451450
"Error loading workspace. (k)ill, (a)ttach, (d)etach?",
452451
choices=["k", "a", "d"],
453-
# value_proc=_validate_choices(["k", "a", "d"]),
454452
default="k",
455453
)
456454

src/tmuxp/cli/utils.py

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from colorama import Fore
88

9-
from .. import config, log
9+
from .. import log
1010
from .constants import VALID_CONFIG_DIR_FILE_EXTENSIONS
1111

1212
logger = logging.getLogger(__name__)
@@ -63,33 +63,6 @@ def get_config_dir() -> str:
6363
return path
6464

6565

66-
def _validate_choices(options: t.List[str]) -> t.Callable:
67-
"""
68-
Callback wrapper for validating click.prompt input.
69-
70-
Parameters
71-
----------
72-
options : list
73-
List of allowed choices
74-
75-
Returns
76-
-------
77-
:func:`callable`
78-
callback function for value_proc in :func:`click.prompt`.
79-
80-
Raises
81-
------
82-
:class:`click.BadParameter`
83-
"""
84-
85-
def func(value):
86-
if value not in options:
87-
raise ValueError("Possible choices are: {}.".format(", ".join(options)))
88-
return value
89-
90-
return func
91-
92-
9366
def get_abs_path(config: str) -> str:
9467
path = os.path
9568
join, isabs = path.join, path.isabs

tests/test_cli.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
load_workspace,
2525
)
2626
from tmuxp.cli.utils import (
27-
_validate_choices,
2827
get_abs_path,
2928
get_config_dir,
3029
is_pure_name,
@@ -1152,16 +1151,6 @@ def test_get_teamocil_dir(monkeypatch: pytest.MonkeyPatch) -> None:
11521151
assert get_teamocil_dir() == os.path.expanduser("~/.teamocil/")
11531152

11541153

1155-
def test_validate_choices() -> None:
1156-
validate = _validate_choices(["choice1", "choice2"])
1157-
1158-
assert validate("choice1")
1159-
assert validate("choice2")
1160-
1161-
with pytest.raises(ValueError):
1162-
assert validate("choice3")
1163-
1164-
11651154
def test_pass_config_dir_ClickPath(
11661155
tmp_path: pathlib.Path,
11671156
monkeypatch: pytest.MonkeyPatch,

0 commit comments

Comments
 (0)