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

Method _find_attributes

Lib/_pyrepl/_module_completer.py:176–193  ·  view source on GitHub ↗
(self, path: str, prefix: str)

Source from the content-addressed store, hash-verified

174 return [attr for attr in attributes if attr.isidentifier()], action
175
176 def _find_attributes(self, path: str, prefix: str) -> tuple[list[str], CompletionAction | None]:
177 path = self._resolve_relative_path(path) # type: ignore[assignment]
178 if path is None:
179 return [], None
180
181 imported_module = sys.modules.get(path)
182 if not imported_module:
183 if path in self._failed_imports: # Do not propose to import again
184 return [], None
185 imported_module = self._maybe_import_module(path)
186 if not imported_module:
187 return [], self._get_import_completion_action(path)
188 try:
189 module_attributes = dir(imported_module)
190 except Exception:
191 module_attributes = []
192 return [attr_name for attr_name in module_attributes
193 if self.is_suggestion_match(attr_name, prefix)], None
194
195 def is_suggestion_match(self, module_name: str, prefix: str) -> bool:
196 if prefix:

Callers 1

find_attributesMethod · 0.95

Calls 5

_maybe_import_moduleMethod · 0.95
is_suggestion_matchMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected