MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / from_values

Method from_values

cmd2/completion.py:226–233  ·  view source on GitHub ↗

Create a CompletionItem instance from arbitrary objects. :param values: the raw objects (e.g. strs, ints, Paths) to be converted into CompletionItems. :param is_sorted: whether the values are already in the desired order.

(cls, values: Iterable[Any], *, is_sorted: bool = False)

Source from the content-addressed store, hash-verified

224
225 @classmethod
226 def from_values(cls, values: Iterable[Any], *, is_sorted: bool = False) -> Self:
227 """Create a CompletionItem instance from arbitrary objects.
228
229 :param values: the raw objects (e.g. strs, ints, Paths) to be converted into CompletionItems.
230 :param is_sorted: whether the values are already in the desired order.
231 """
232 items = [v if isinstance(v, CompletionItem) else CompletionItem(value=v) for v in values]
233 return cls(items=items, is_sorted=is_sorted)
234
235 def to_strings(self) -> tuple[str, ...]:
236 """Return a tuple of the completion strings (the 'text' field of each item)."""

Callers 15

get_bool_choicesMethod · 0.80
complete_fooMethod · 0.80
complete_barMethod · 0.80
complete_foo_valMethod · 0.80
completedefaultMethod · 0.80
test_command_completionFunction · 0.80
test_complete_macroFunction · 0.80
test_help_completionFunction · 0.80

Calls 1

CompletionItemClass · 0.85

Tested by 15

complete_fooMethod · 0.64
complete_barMethod · 0.64
complete_foo_valMethod · 0.64
completedefaultMethod · 0.64
test_command_completionFunction · 0.64
test_complete_macroFunction · 0.64
test_help_completionFunction · 0.64