From 2fcd2f8f892852766da02783f64bcdee59dabd58 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Fri, 14 Jul 2017 18:21:52 +0200 Subject: [PATCH] Fix some more stuff because of newer parso changes. --- jedi/api/helpers.py | 5 +++-- jedi/evaluate/context.py | 2 +- jedi/evaluate/pep0484.py | 2 +- test/completion/arrays.py | 2 +- test/test_parso_integration/test_parser_utils.py | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/jedi/api/helpers.py b/jedi/api/helpers.py index 53e920f0..34f76daa 100644 --- a/jedi/api/helpers.py +++ b/jedi/api/helpers.py @@ -7,7 +7,6 @@ from textwrap import dedent from parso.python.parser import Parser from parso.python import tree -from parso.python.tokenize import tokenize from parso.utils import splitlines from jedi._compatibility import u @@ -121,7 +120,9 @@ def get_stack_at_position(grammar, code_lines, module_node, pos): pass def tokenize_without_endmarker(code): - tokens = tokenize(code) + # TODO This is for now not an official parso API that exists purely + # for Jedi. + tokens = grammar._tokenize(code) for token_ in tokens: if token_.string == safeword: raise EndMarkerReached() diff --git a/jedi/evaluate/context.py b/jedi/evaluate/context.py index eda194ca..0c91af2e 100644 --- a/jedi/evaluate/context.py +++ b/jedi/evaluate/context.py @@ -180,7 +180,7 @@ class ContextualizedName(ContextualizedNode): node = self._node.parent compare = self._node while node is not None: - if node.type in ('testlist_comp', 'testlist_star_expr', 'exprlist'): + if node.type in ('testlist', 'testlist_comp', 'testlist_star_expr', 'exprlist'): for i, child in enumerate(node.children): if child == compare: indexes.insert(0, (int(i / 2), node)) diff --git a/jedi/evaluate/pep0484.py b/jedi/evaluate/pep0484.py index 12964231..c87a967a 100644 --- a/jedi/evaluate/pep0484.py +++ b/jedi/evaluate/pep0484.py @@ -199,7 +199,7 @@ def find_type_from_comment_hint_assign(context, node, name): def _find_type_from_comment_hint(context, node, varlist, name): index = None - if varlist.type in ("testlist_star_expr", "exprlist"): + if varlist.type in ("testlist_star_expr", "exprlist", "testlist"): # something like "a, b = 1, 2" index = 0 for child in varlist.children: diff --git a/test/completion/arrays.py b/test/completion/arrays.py index c00e2859..2f23a2ce 100644 --- a/test/completion/arrays.py +++ b/test/completion/arrays.py @@ -404,7 +404,7 @@ def test_func(): #? str() x - +# python >= 3.3 # ----------------- # PEP 3132 Extended Iterable Unpacking (star unpacking) # ----------------- diff --git a/test/test_parso_integration/test_parser_utils.py b/test/test_parso_integration/test_parser_utils.py index 11c62d8e..07ce341a 100644 --- a/test/test_parso_integration/test_parser_utils.py +++ b/test/test_parso_integration/test_parser_utils.py @@ -80,7 +80,7 @@ def test_hex_values_in_docstring(): ('lambda x, y, z: x + y * z\n', '(x, y, z)') ]) def test_get_call_signature(code, call_signature): - node = parse(code).children[0] + node = parse(code, version='3.5').children[0] if node.type == 'simple_stmt': node = node.children[0] assert parser_utils.get_call_signature(node) == call_signature