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

Method complete

Lib/_pyrepl/_module_completer.py:91–108  ·  view source on GitHub ↗
(self, from_name: str | None, name: str | None)

Source from the content-addressed store, hash-verified

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:
93 # import x.y.z<tab>
94 assert name is not None
95 path, prefix = self.get_path_and_prefix(name)
96 modules = self.find_modules(path, prefix)
97 return [self.format_completion(path, module) for module in modules], None
98
99 if name is None:
100 # from x.y.z<tab>
101 path, prefix = self.get_path_and_prefix(from_name)
102 modules = self.find_modules(path, prefix)
103 return [self.format_completion(path, module) for module in modules], None
104
105 # from x.y import z<tab>
106 submodules = self.find_modules(from_name, name)
107 attributes, action = self.find_attributes(from_name, name)
108 return sorted({*submodules, *attributes}), action
109
110 def find_modules(self, path: str, prefix: str) -> list[str]:
111 """Find all modules under 'path' that start with 'prefix'."""

Callers 1

get_completionsMethod · 0.95

Calls 4

get_path_and_prefixMethod · 0.95
find_modulesMethod · 0.95
format_completionMethod · 0.95
find_attributesMethod · 0.95

Tested by

no test coverage detected