MCPcopy
hub / github.com/prompt-toolkit/ptpython / get_completions

Method get_completions

src/ptpython/completer.py:632–657  ·  view source on GitHub ↗
(
        self, document: Document, complete_event: CompleteEvent
    )

Source from the content-addressed store, hash-verified

630 self.complete_private_attributes = complete_private_attributes
631
632 def get_completions(
633 self, document: Document, complete_event: CompleteEvent
634 ) -> Iterable[Completion]:
635 completions = list(
636 # Limit at 5k completions for performance.
637 islice(self.completer.get_completions(document, complete_event), 0, 5000)
638 )
639 complete_private_attributes = self.complete_private_attributes()
640 hide_private = False
641
642 def is_private(completion: Completion) -> bool:
643 text = fragment_list_to_text(to_formatted_text(completion.display))
644 return text.startswith("_")
645
646 if complete_private_attributes == CompletePrivateAttributes.NEVER:
647 hide_private = True
648
649 elif complete_private_attributes == CompletePrivateAttributes.IF_NO_PUBLIC:
650 hide_private = any(not is_private(completion) for completion in completions)
651
652 if hide_private:
653 completions = [
654 completion for completion in completions if not is_private(completion)
655 ]
656
657 return completions
658
659
660class ReprFailedError(Exception):

Callers

nothing calls this directly

Calls 1

get_completionsMethod · 0.45

Tested by

no test coverage detected