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

Method set_custom_completer

IPython/core/interactiveshell.py:2214–2230  ·  view source on GitHub ↗

Adds a new custom completer function. The position argument (defaults to 0) is the index in the completers list where you want the completer to be inserted. `completer` should have the following signature:: def completion(self: Completer, text: string) -> List[

(self, completer, pos=0)

Source from the content-addressed store, hash-verified

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.
2216
2217 The position argument (defaults to 0) is the index in the completers
2218 list where you want the completer to be inserted.
2219
2220 `completer` should have the following signature::
2221
2222 def completion(self: Completer, text: string) -> List[str]:
2223 raise NotImplementedError
2224
2225 It will be bound to the current Completer instance and pass some text
2226 and return a list with current completions to suggest to the user.
2227 """
2228
2229 newcomp = types.MethodType(completer, self.Completer)
2230 self.Completer.custom_matchers.insert(pos,newcomp)
2231
2232 def set_completer_frame(self, frame=None):
2233 """Set the frame of the completer."""

Callers 1

Calls

no outgoing calls

Tested by 1