1
0
forked from VimPlug/jedi

Add a latest grammar to the evaluator and use it to avoid importing from parso import parse.

This commit is contained in:
Dave Halter
2017-05-24 00:37:36 -04:00
parent b90589b62e
commit cd8932fbfc
10 changed files with 31 additions and 26 deletions

View File

@@ -22,7 +22,6 @@ from jedi._compatibility import u
from jedi.common import unite
from jedi.evaluate import context
from jedi.evaluate.cache import memoize_default
from parso.python import parse
from jedi.common import indent_block
from jedi.evaluate.iterable import SequenceLiteralContext, FakeSequence
@@ -132,7 +131,8 @@ def _evaluate_for_statement_string(module_context, string):
# Take the default grammar here, if we load the Python 2.7 grammar here, it
# will be impossible to use `...` (Ellipsis) as a token. Docstring types
# don't need to conform with the current grammar.
module = parse(code.format(indent_block(string)))
grammar = module_context.evaluator.latest_grammar
module = grammar.parse(code.format(indent_block(string)))
try:
funcdef = next(module.iter_funcdefs())
# First pick suite, then simple_stmt and then the node,