Skip to content

Commit 2769bb5

Browse files
authored
Merge branch 'main' into fix-union-types
2 parents 8e11e9a + cd483f2 commit 2769bb5

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

IPython/core/completer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,6 +1352,8 @@ def _trim_expr(self, code: str) -> str:
13521352
assert res is not None
13531353
if len(res.body) != 1:
13541354
continue
1355+
if not isinstance(res.body[0], ast.Expr):
1356+
continue
13551357
expr = res.body[0].value
13561358
if isinstance(expr, ast.Tuple) and not code[-1] == ")":
13571359
# we skip implicit tuple, like when trimming `fun(a,b`<completion>

tests/test_completer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2743,6 +2743,7 @@ def test_misc_no_jedi_completions(setup, code, expected, not_expected):
27432743
("x = {1, y", "y"),
27442744
("x = [1, y", "y"),
27452745
("x = fun(1, y", "y"),
2746+
(" assert a", "a"),
27462747
],
27472748
)
27482749
def test_trim_expr(code, expected):

0 commit comments

Comments
 (0)