diff --git a/jedi/evaluate/representation.py b/jedi/evaluate/representation.py index 8c54028a..8b921ab5 100644 --- a/jedi/evaluate/representation.py +++ b/jedi/evaluate/representation.py @@ -431,7 +431,6 @@ class Class(use_metaclass(CachedMetaClass, Wrapper)): yield self.names_dict else: for scope in self.py__mro__(self._evaluator): - print(scope.names_dict) if isinstance(scope, compiled.CompiledObject): yield scope.names_dicts(False, is_instance)[0] else: diff --git a/jedi/parser/__init__.py b/jedi/parser/__init__.py index 4a5cad4c..3a03b308 100644 --- a/jedi/parser/__init__.py +++ b/jedi/parser/__init__.py @@ -106,8 +106,8 @@ class Parser(object): } self.global_names = [] + self._omit_dedent = 0 - print('start') # TODO do print absolute import detection here. #try: # del python_grammar_no_print_statement.keywords["print"] @@ -231,6 +231,11 @@ class Parser(object): #print('err', token.tok_name[typ], repr(value), start_pos, len(stack), index) self._stack_removal(grammar, stack, index + 1, value, start_pos) + if typ == token.INDENT: + # For every deleted INDENT we got to delete a DEDENT as well. + # Otherwise the parser will get into trouble and DEDENT too early. + self._omit_dedent += 1 + if value in ('import', 'from', 'class', 'def', 'try', 'while', 'return'): # Those can always be new statements. add_token_callback(typ, value, prefix, start_pos) @@ -280,6 +285,10 @@ class Parser(object): def _tokenize(self, tokenizer): for typ, value, start_pos, prefix in tokenizer: + if self._omit_dedent and typ == token.DEDENT: + self._omit_dedent -= 1 + continue + if typ == token.OP: typ = token.opmap[value] yield typ, value, prefix, start_pos diff --git a/test/completion/invalid.py b/test/completion/invalid.py index 9a5ce319..97b3b7a2 100644 --- a/test/completion/invalid.py +++ b/test/completion/invalid.py @@ -31,8 +31,7 @@ def wrong_indents(): asdf = 3 asdf asdf( - # doesn't work because of the indent issues. - #? str() + #? int() asdf def openbrace(): asdf = 3 @@ -104,6 +103,7 @@ try: #? str() "" +def break(): pass # wrong ternary expression a = '' a = 1 if