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)
| 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).""" |