MCPcopy Index your code
hub / github.com/python/cpython / complete

Method complete

Lib/pdb.py:3368–3413  ·  view source on GitHub ↗
(self, text, state)

Source from the content-addressed store, hash-verified

3366 return
3367
3368 def complete(self, text, state):
3369 import readline
3370
3371 if state == 0:
3372 self.completion_matches = []
3373 if self.state not in ("pdb", "interact"):
3374 return None
3375
3376 origline = readline.get_line_buffer()
3377 line = origline.lstrip()
3378 if self.multiline_block:
3379 # We're completing a line contained in a multi-line block.
3380 # Force the remote to treat it as a Python expression.
3381 line = "! " + line
3382 offset = len(origline) - len(line)
3383 begidx = readline.get_begidx() - offset
3384 endidx = readline.get_endidx() - offset
3385
3386 msg = {
3387 "complete": {
3388 "text": text,
3389 "line": line,
3390 "begidx": begidx,
3391 "endidx": endidx,
3392 }
3393 }
3394
3395 self._send(**msg)
3396 if self.write_failed:
3397 return None
3398
3399 payload = self._readline()
3400 if not payload:
3401 return None
3402
3403 payload = json.loads(payload)
3404 if "completions" not in payload:
3405 raise RuntimeError(
3406 f"Failed to get valid completions. Got: {payload}"
3407 )
3408
3409 self.completion_matches = payload["completions"]
3410 try:
3411 return self.completion_matches[state]
3412 except IndexError:
3413 return None
3414
3415
3416def _connect(

Callers 1

completedefaultMethod · 0.45

Calls 7

_sendMethod · 0.95
_readlineMethod · 0.95
get_line_bufferMethod · 0.80
get_begidxMethod · 0.80
get_endidxMethod · 0.80
lstripMethod · 0.45
loadsMethod · 0.45

Tested by

no test coverage detected