MCPcopy Index your code
hub / github.com/ipython/ipython / _deduplicate_completions

Function _deduplicate_completions

IPython/core/completer.py:797–836  ·  view source on GitHub ↗

Deduplicate a set of completions. .. warning:: Unstable This function is unstable, API may change without warning. Parameters ---------- text : str text that should be completed. completions : Iterator[Completion] iterator over the complet

(text: str, completions: _IC)

Source from the content-addressed store, hash-verified

795
796
797def _deduplicate_completions(text: str, completions: _IC)-> _IC:
798 """
799 Deduplicate a set of completions.
800
801 .. warning::
802
803 Unstable
804
805 This function is unstable, API may change without warning.
806
807 Parameters
808 ----------
809 text : str
810 text that should be completed.
811 completions : Iterator[Completion]
812 iterator over the completions to deduplicate
813
814 Yields
815 ------
816 `Completions` objects
817 Completions coming from multiple sources, may be different but end up having
818 the same effect when applied to ``text``. If this is the case, this will
819 consider completions as equal and only emit the first encountered.
820 Not folded in `completions()` yet for debugging purpose, and to detect when
821 the IPython completer does return things that Jedi does not, but should be
822 at some point.
823 """
824 completions = list(completions)
825 if not completions:
826 return
827
828 new_start = min(c.start for c in completions)
829 new_end = max(c.end for c in completions)
830
831 seen = set()
832 for c in completions:
833 new_text = text[new_start:c.start] + c.text + text[c.end:new_end]
834 if new_text not in seen:
835 yield c
836 seen.add(new_text)
837
838
839def rectify_completions(text: str, completions: _IC, *, _debug: bool = False) -> _IC:

Callers 2

_get_completionsMethod · 0.90

Calls 1

addMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…