diff --git a/jedi/evaluate/imports.py b/jedi/evaluate/imports.py index 5fadd3dc..4fbf1278 100644 --- a/jedi/evaluate/imports.py +++ b/jedi/evaluate/imports.py @@ -460,7 +460,7 @@ class _Importer(object): def follow_file_system(self): # Handle "magic" Flask extension imports: # ``flask.ext.foo`` is really ``flask_foo`` or ``flaskext.foo``. - if len(self.import_path) > 2 and self.str_import_path()[:2] == ('flask', 'ext'): + if len(self.import_path) > 2 and self.str_import_path[:2] == ('flask', 'ext'): orig_path = tuple(self.import_path) part = orig_path[2] pos = (part._line, part._column) @@ -633,7 +633,7 @@ class _Importer(object): if self.import_path: for scope in self.follow(evaluator): # flask - if self.str_import_path() == ('flask', 'ext'): + if self.str_import_path == ('flask', 'ext'): # List Flask extensions like ``flask_foo`` for mod in self._get_module_names(): modname = str(mod) diff --git a/jedi/parser/__init__.py b/jedi/parser/__init__.py index 51b7ab82..dcbba22e 100644 --- a/jedi/parser/__init__.py +++ b/jedi/parser/__init__.py @@ -222,9 +222,23 @@ class Parser(object): elif symbol == 'suite' and len(nodes) > 1: # suites without an indent in them get discarded. break + elif symbol == 'simple_stmt' and len(nodes) > 1: + # simple_stmt can just be turned into a Node, if there are + # enough statements. Ignore the rest after that. + break return index, symbol, nodes index, symbol, nodes = current_suite(stack) + if symbol == 'simple_stmt': + index -= 1 + (_, _, (typ, suite_nodes)) = stack[index] + symbol = grammar.number2symbol[typ] + suite_nodes.append(pt.Node(symbol, list(nodes))) + # Remove + nodes[:] = [] + nodes = suite_nodes + stack[index] + #print('err', tokenize.tok_name[typ], repr(value), start_pos, len(stack), index) self._stack_removal(grammar, stack, index + 1, value, start_pos) if value in ('import', 'from', 'class', 'def', 'try', 'while', 'return'):