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

Method attr_matches

bpython/autocomplete.py:419–437  ·  view source on GitHub ↗

Taken from rlcompleter.py and bent to my will.

(
        self, text: str, namespace: dict[str, Any]
    )

Source from the content-addressed store, hash-verified

417 return _after_last_dot(word)
418
419 def attr_matches(
420 self, text: str, namespace: dict[str, Any]
421 ) -> Iterator[str]:
422 """Taken from rlcompleter.py and bent to my will."""
423
424 m = self.attr_matches_re.match(text)
425 if not m:
426 return (_ for _ in ())
427
428 expr, attr = m.group(1, 3)
429 if expr.isdigit():
430 # Special case: float literal, using attrs here will result in
431 # a SyntaxError
432 return (_ for _ in ())
433 try:
434 obj = safe_eval(expr, namespace)
435 except EvaluationError:
436 return (_ for _ in ())
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."""

Callers 1

matchesMethod · 0.95

Calls 3

attr_lookupMethod · 0.95
safe_evalFunction · 0.85
matchMethod · 0.80

Tested by

no test coverage detected