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

Method complete

IPython/core/interactiveshell.py:2169–2212  ·  view source on GitHub ↗

Return the completed text and a list of completions. Parameters ---------- text : string A string of text to be completed on. It can be given as empty and instead a line/position pair are given. In this case, the completer itself

(self, text, line=None, cursor_pos=None)

Source from the content-addressed store, hash-verified

2167
2168 @skip_doctest
2169 def complete(self, text, line=None, cursor_pos=None):
2170 """Return the completed text and a list of completions.
2171
2172 Parameters
2173 ----------
2174
2175 text : string
2176 A string of text to be completed on. It can be given as empty and
2177 instead a line/position pair are given. In this case, the
2178 completer itself will split the line like readline does.
2179
2180 line : string, optional
2181 The complete line that text is part of.
2182
2183 cursor_pos : int, optional
2184 The position of the cursor on the input line.
2185
2186 Returns
2187 -------
2188 text : string
2189 The actual text that was completed.
2190
2191 matches : list
2192 A sorted list with all possible completions.
2193
2194 The optional arguments allow the completion to take more context into
2195 account, and are part of the low-level completion API.
2196
2197 This is a wrapper around the completion mechanism, similar to what
2198 readline does at the command line when the TAB key is hit. By
2199 exposing it as a method, it can be used by other non-readline
2200 environments (such as GUIs) for text completion.
2201
2202 Simple usage example:
2203
2204 In [1]: x = 'hello'
2205
2206 In [2]: _ip.complete('x.l')
2207 Out[2]: ('x.l', ['x.ljust', 'x.lower', 'x.lstrip'])
2208 """
2209
2210 # Inject names into __builtin__ so we can complete on the added names.
2211 with self.builtin_trap:
2212 return self.Completer.complete(text, line, cursor_pos)
2213
2214 def set_custom_completer(self, completer, pos=0) -> None:
2215 """Adds a new custom completer function.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected