From 6a8b160e1b65db0298bc3581e20099dfa19d25e9 Mon Sep 17 00:00:00 2001 From: David Halter Date: Tue, 16 Oct 2012 13:56:10 +0200 Subject: [PATCH] nested list comprehension with brackets: parser failed; fixes #26 --- jedi/parsing.py | 2 +- test/completion/basic.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/jedi/parsing.py b/jedi/parsing.py index 3b157859..2dbb2340 100644 --- a/jedi/parsing.py +++ b/jedi/parsing.py @@ -1464,7 +1464,7 @@ class PyFuzzyParser(object): other_level = 0 for i, tok in enumerate(reversed(tok_list)): - if not isinstance(tok, Name): + if not isinstance(tok, (Name, ListComprehension)): tok = tok[1] if tok in closing_brackets: other_level -= 1 diff --git a/test/completion/basic.py b/test/completion/basic.py index 758f85ed..2f4ce28b 100644 --- a/test/completion/basic.py +++ b/test/completion/basic.py @@ -134,6 +134,14 @@ b = [b for arr in [[[1.0]]] for a in arr for b in a] #? float() b[0] +# jedi issue #26 +#? list() +a = [[int(v) for v in line.strip().split() if v] for line in ["123", "123", "123"] if line] +#? list() +a[0] +#? int() +a[0][0] + # ----------------- # ternary operator # -----------------