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

Method attr_matches

Lib/_pyrepl/fancycompleter.py:86–108  ·  view source on GitHub ↗
(self, text)

Source from the content-addressed store, hash-verified

84 return names
85
86 def attr_matches(self, text):
87 try:
88 expr, attr, names, values = self._attr_matches(text)
89 except ValueError:
90 return []
91
92 if not names:
93 return []
94
95 if len(names) == 1:
96 # No coloring: when returning a single completion, readline
97 # inserts it directly into the prompt, so ANSI codes would
98 # appear as literal characters.
99 return [self._callable_attr_postfix(values[0], f'{expr}.{names[0]}')]
100
101 prefix = commonprefix(names)
102 if prefix and prefix != attr:
103 return [f'{expr}.{prefix}'] # autocomplete prefix
104
105 names = [f'{expr}.{name}' for name in names]
106 if self.use_colors:
107 return self.colorize_matches(names, values)
108 return names
109
110 def _attr_matches(self, text):
111 expr, attr = text.rsplit('.', 1)

Calls 4

_attr_matchesMethod · 0.95
colorize_matchesMethod · 0.95
commonprefixFunction · 0.70