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)
| 795 | |
| 796 | |
| 797 | def _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 | |
| 839 | def rectify_completions(text: str, completions: _IC, *, _debug: bool = False) -> _IC: |
searching dependent graphs…