MCPcopy Create free account
hub / github.com/ipython/ipython / completions

Method completions

IPython/core/completer.py:1766–1826  ·  view source on GitHub ↗

Returns an iterator over the possible completions .. warning:: Unstable This function is unstable, API may change without warning. It will also raise unless use in proper context manager. Parameters ---------- text:str

(self, text: str, offset: int)

Source from the content-addressed store, hash-verified

1764 return None
1765
1766 def completions(self, text: str, offset: int)->Iterator[Completion]:
1767 """
1768 Returns an iterator over the possible completions
1769
1770 .. warning:: Unstable
1771
1772 This function is unstable, API may change without warning.
1773 It will also raise unless use in proper context manager.
1774
1775 Parameters
1776 ----------
1777
1778 text:str
1779 Full text of the current input, multi line string.
1780 offset:int
1781 Integer representing the position of the cursor in ``text``. Offset
1782 is 0-based indexed.
1783
1784 Yields
1785 ------
1786 :any:`Completion` object
1787
1788
1789 The cursor on a text can either be seen as being "in between"
1790 characters or "On" a character depending on the interface visible to
1791 the user. For consistency the cursor being on "in between" characters X
1792 and Y is equivalent to the cursor being "on" character Y, that is to say
1793 the character the cursor is on is considered as being after the cursor.
1794
1795 Combining characters may span more that one position in the
1796 text.
1797
1798
1799 .. note::
1800
1801 If ``IPCompleter.debug`` is :any:`True` will yield a ``--jedi/ipython--``
1802 fake Completion token to distinguish completion returned by Jedi
1803 and usual IPython completion.
1804
1805 .. note::
1806
1807 Completions are not completely deduplicated yet. If identical
1808 completions are coming from different sources this function does not
1809 ensure that each completion object will only be present once.
1810 """
1811 warnings.warn("_complete is a provisional API (as of IPython 6.0). "
1812 "It may change without warnings. "
1813 "Use in corresponding context manager.",
1814 category=ProvisionalCompleterWarning, stacklevel=2)
1815
1816 seen = set()
1817 try:
1818 for c in self._completions(text, offset, _timeout=self.jedi_compute_type_timeout/1000):
1819 if c and (c in seen):
1820 continue
1821 yield c
1822 seen.add(c)
1823 except KeyboardInterrupt:

Callers 8

all_completionsMethod · 0.95
_get_completionsMethod · 0.80
_jedi_matchesMethod · 0.80
_test_completeMethod · 0.80
_test_not_completeMethod · 0.80
_Method · 0.80

Calls 3

_completionsMethod · 0.95
warnMethod · 0.80
addMethod · 0.45

Tested by 5

_test_completeMethod · 0.64
_test_not_completeMethod · 0.64
_Method · 0.64