Skip to content

Commit 167fc26

Browse files
committed
Hide implementation details
1 parent 424345e commit 167fc26

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

bpython/autocomplete.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,11 @@ def from_string(cls, value: str) -> Optional["AutocompleteModes"]:
176176
KEYWORDS = frozenset(keyword.kwlist)
177177

178178

179-
def after_last_dot(name: str) -> str:
179+
def _after_last_dot(name: str) -> str:
180180
return name.rstrip(".").rsplit(".")[-1]
181181

182182

183-
def few_enough_underscores(current: str, match: str) -> bool:
183+
def _few_enough_underscores(current: str, match: str) -> bool:
184184
"""Returns whether match should be shown based on current
185185
186186
if current is _, True if match starts with 0 or 1 underscore
@@ -340,7 +340,7 @@ def locate(self, cursor_offset: int, line: str) -> Optional[LinePart]:
340340
return lineparts.current_word(cursor_offset, line)
341341

342342
def format(self, word: str) -> str:
343-
return after_last_dot(word)
343+
return _after_last_dot(word)
344344

345345

346346
def _safe_glob(pathname: str) -> Iterator[str]:
@@ -409,14 +409,14 @@ def matches(
409409
return {
410410
m
411411
for m in matches
412-
if few_enough_underscores(r.word.split(".")[-1], m.split(".")[-1])
412+
if _few_enough_underscores(r.word.split(".")[-1], m.split(".")[-1])
413413
}
414414

415415
def locate(self, cursor_offset: int, line: str) -> Optional[LinePart]:
416416
return lineparts.current_dotted_attribute(cursor_offset, line)
417417

418418
def format(self, word: str) -> str:
419-
return after_last_dot(word)
419+
return _after_last_dot(word)
420420

421421
def attr_matches(self, text: str, namespace: Dict[str, Any]) -> List:
422422
"""Taken from rlcompleter.py and bent to my will."""
@@ -434,8 +434,7 @@ def attr_matches(self, text: str, namespace: Dict[str, Any]) -> List:
434434
obj = safe_eval(expr, namespace)
435435
except EvaluationError:
436436
return []
437-
matches = self.attr_lookup(obj, expr, attr)
438-
return matches
437+
return self.attr_lookup(obj, expr, attr)
439438

440439
def attr_lookup(self, obj: Any, expr: str, attr: str) -> List:
441440
"""Second half of attr_matches."""
@@ -631,7 +630,7 @@ def matches(
631630

632631
# strips leading dot
633632
matches = (m[1:] for m in self.attr_lookup(obj, "", attr.word))
634-
return {m for m in matches if few_enough_underscores(attr.word, m)}
633+
return {m for m in matches if _few_enough_underscores(attr.word, m)}
635634

636635

637636
try:

bpython/test/test_autocomplete.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_filename(self):
3535
self.assertEqual(last_part_of_filename("ab.c/e.f.g/"), "e.f.g/")
3636

3737
def test_attribute(self):
38-
self.assertEqual(autocomplete.after_last_dot("abc.edf"), "edf")
38+
self.assertEqual(autocomplete._after_last_dot("abc.edf"), "edf")
3939

4040

4141
def completer(matches):

0 commit comments

Comments
 (0)