MCPcopy Index your code
hub / github.com/bpython/bpython / attr_lookup

Method attr_lookup

bpython/autocomplete.py:439–457  ·  view source on GitHub ↗

Second half of attr_matches.

(self, obj: Any, expr: str, attr: str)

Source from the content-addressed store, hash-verified

437 return self.attr_lookup(obj, expr, attr)
438
439 def attr_lookup(self, obj: Any, expr: str, attr: str) -> Iterator[str]:
440 """Second half of attr_matches."""
441 words = self.list_attributes(obj)
442 if inspection.hasattr_safe(obj, "__class__"):
443 words.append("__class__")
444 klass = inspection.getattr_safe(obj, "__class__")
445 words = words + rlcompleter.get_class_members(klass)
446 if not isinstance(klass, abc.ABCMeta):
447 try:
448 words.remove("__abstractmethods__")
449 except ValueError:
450 pass
451
452 n = len(attr)
453 return (
454 f"{expr}.{word}"
455 for word in words
456 if self.method_match(word, n, attr) and word != "__builtins__"
457 )
458
459 def list_attributes(self, obj: Any) -> list[str]:
460 # TODO: re-implement dir without AttrCleaner here

Callers 2

attr_matchesMethod · 0.95
matchesMethod · 0.80

Calls 2

list_attributesMethod · 0.95
appendMethod · 0.80

Tested by

no test coverage detected