Skip to content

Commit e62c4ba

Browse files
committed
fix-completions-for-private-attr
1 parent 11e1f40 commit e62c4ba

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

IPython/core/completer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2608,8 +2608,8 @@ def _determine_completion_context(self, line):
26082608
if re.search(r"(?<!\w)(?<!\d\.)([-+]?\d+\.(\d+)?)(?!\w)$", line):
26092609
return self._CompletionContextType.GLOBAL
26102610

2611-
# Handle all other attribute matches np.ran, d[0].k, (a,b).count
2612-
chain_match = re.search(r".*(.+(?<!\s)\.(?:[a-zA-Z]\w*)?)$", line)
2611+
# Handle all other attribute matches np.ran, d[0].k, (a,b).count, obj._private
2612+
chain_match = re.search(r".*(.+(?<!\s)\.(?:[a-zA-Z_]\w*)?)$", line)
26132613
if chain_match:
26142614
return self._CompletionContextType.ATTRIBUTE
26152615

tests/test_completer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2739,6 +2739,8 @@ def test_no_file_completions_in_attr_access(code):
27392739
("dict_with_dots = {'key.with.dots': value.attr", "attribute"),
27402740
("d[f'{a}']['{a.", "global"),
27412741
("ls .", "global"),
2742+
("t._", "attribute"),
2743+
("t.__a", "attribute"),
27422744
],
27432745
)
27442746
def test_completion_context(line, expected):

0 commit comments

Comments
 (0)