Skip to content

Commit b370588

Browse files
committed
Fixed type issues.
1 parent ad8ec9e commit b370588

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

cmd2/argparse_completer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
)
3737
from .command_definition import CommandSet
3838
from .completion import (
39-
Choices,
4039
CompletionItem,
4140
Completions,
4241
all_display_numeric,
@@ -698,7 +697,9 @@ def _get_raw_choices(self, arg_state: _ArgumentState) -> list[CompletionItem] |
698697
]
699698

700699
# Standard choices
701-
return Choices.from_values(arg_state.action.choices)
700+
return [
701+
choice if isinstance(choice, CompletionItem) else CompletionItem(choice) for choice in arg_state.action.choices
702+
]
702703

703704
choices_callable: ChoicesCallable | None = arg_state.action.get_choices_callable() # type: ignore[attr-defined]
704705
return choices_callable

cmd2/completion.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from collections.abc import (
66
Callable,
77
Collection,
8+
Iterable,
89
Iterator,
910
Sequence,
1011
)
@@ -149,7 +150,7 @@ def __post_init__(self) -> None:
149150
object.__setattr__(self, "items", tuple(unique_items))
150151

151152
@classmethod
152-
def from_values(cls, values: Iterator[Any], *, is_sorted: bool = False) -> Self:
153+
def from_values(cls, values: Iterable[Any], *, is_sorted: bool = False) -> Self:
153154
"""Create a CompletionItem instance from arbitrary objects.
154155
155156
:param values: the raw objects (e.g. strs, ints, Paths) to be converted into CompletionItems.

0 commit comments

Comments
 (0)