◐ Shell
reader mode source ↗
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
17 changes: 13 additions & 4 deletions bpython/autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ def from_string(cls, value):


def after_last_dot(name):
return name.rstrip(".").rsplit(".")[-1]


Expand Down Expand Up @@ -213,7 +215,9 @@ def __init__(self, shown_before_tab=True, mode=AutocompleteModes.SIMPLE):

def matches(self, cursor_offset, line, **kwargs):
"""Returns a list of possible matches given a line and cursor, or None
if this completion type isn't applicable.

ie, import completion doesn't make sense if there cursor isn't after
an import or from statement, so it ought to return None.
Expand Down Expand Up @@ -413,7 +417,12 @@ def attr_lookup(self, obj, expr, attr):
n = len(attr)
for word in words:
if self.method_match(word, n, attr) and word != "__builtins__":
matches.append(f"{expr}.{word}")
return matches

def list_attributes(self, obj):
Expand Down Expand Up @@ -690,6 +699,6 @@ def get_default_completer(mode=AutocompleteModes.SIMPLE, module_gatherer=None):

def _callable_postfix(value, word):
"""rlcompleter's _callable_postfix done right."""
if callable(value):
word += "("
return word
Toggle all file notes Toggle all file annotations