Skip to content

Commit dba1cd6

Browse files
committed
handle_edge_case_1
1 parent 6220937 commit dba1cd6

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

IPython/core/completer.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,12 +1138,18 @@ def _attr_matches(
11381138
self, text: str, include_prefix: bool = True
11391139
) -> tuple[Sequence[str], str]:
11401140
# Extract only the right-hand side part of the text after '='
1141-
rhs_text = text.split("=")[-1]
1142-
m2 = self._ATTR_MATCH_RE.match(rhs_text)
1141+
m2 = self._ATTR_MATCH_RE.match(text)
11431142
if not m2:
11441143
return [], ""
11451144
expr, attr = m2.group(1, 2)
11461145

1146+
operators = ["=", "==", "!=", ">=", "<=", ">", "<"]
1147+
# Split by the operator and take the right side
1148+
if not (expr.startswith("(") and expr.endswith(")")):
1149+
for op in operators:
1150+
if op in expr:
1151+
expr = expr.split(op)[-1]
1152+
11471153
obj = self._evaluate_expr(expr)
11481154

11491155
if obj is not_found:

tests/test_completer.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,13 @@ def _(line, cursor_pos, expect, message, completion):
662662
"Should have completed on `x.upper() == y.`: %s",
663663
Completion(15, 15, "upper"),
664664
)
665+
_(
666+
"(x.upper() == y).",
667+
17,
668+
".bit_length",
669+
"Should have completed on `(x.upper() == y).`: %s",
670+
Completion(17, 17, "bit_length"),
671+
)
665672

666673
def test_omit__names(self):
667674
# also happens to test IPCompleter as a configurable

0 commit comments

Comments
 (0)