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

Method get_completions

Lib/_pyrepl/_module_completer.py:74–89  ·  view source on GitHub ↗

Return the next possible import completions for 'line'. For attributes completion, if the module to complete from is not imported, also return an action (prompt + callback to run if the user press TAB again) to import the module.

(self, line: str)

Source from the content-addressed store, hash-verified

72 self._stdlib_path = os.path.dirname(importlib.__path__[0])
73
74 def get_completions(self, line: str) -> tuple[list[str], CompletionAction | None] | None:
75 """Return the next possible import completions for 'line'.
76
77 For attributes completion, if the module to complete from is not
78 imported, also return an action (prompt + callback to run if the
79 user press TAB again) to import the module.
80 """
81 result = ImportParser(line).parse()
82 if not result:
83 return None
84 try:
85 return self.complete(*result)
86 except Exception:
87 # Some unexpected error occurred, make it look like
88 # no completions are available
89 return [], None
90
91 def complete(self, from_name: str | None, name: str | None) -> tuple[list[str], CompletionAction | None]:
92 if from_name is None:

Callers 1

Calls 3

completeMethod · 0.95
ImportParserClass · 0.85
parseMethod · 0.45

Tested by 1