diff --git a/jedi/evaluate.py b/jedi/evaluate.py index 34c651b6..013a561f 100644 --- a/jedi/evaluate.py +++ b/jedi/evaluate.py @@ -791,7 +791,8 @@ def filter_private_variable(scope, call_scope, var_name): def goto(stmt, call_path=None): if call_path is None: commands = stmt.get_commands() - assert len(commands) == 1 + # Only the first command is important, the rest should basically not + # happen except in broken code (e.g. docstrings that aren't code). call = commands[0] if isinstance(call, (str, unicode)): call_path = [call] diff --git a/jedi/parsing_representation.py b/jedi/parsing_representation.py index 48cc6c23..fe50409e 100644 --- a/jedi/parsing_representation.py +++ b/jedi/parsing_representation.py @@ -1114,7 +1114,7 @@ class Statement(Simple): result = [] is_chain = False else: - if tok != '\n': + if tok != '\n' and token_type != tokenize.COMMENT: result.append(tok) return result diff --git a/test/completion/basic.py b/test/completion/basic.py index bd4164e9..c475ed7a 100644 --- a/test/completion/basic.py +++ b/test/completion/basic.py @@ -220,3 +220,14 @@ class B(): pass A.__init__ #? ['__init__'] B.__init__ + + +# ----------------- +# comments +# ----------------- + +class A(): + def __init__(self): + self.hello = {} # comment shouldn't be a string +#? dict() +A().hello