diff --git a/jedi/evaluate/pep0484.py b/jedi/evaluate/pep0484.py index 7b97a89a..7519ce3b 100644 --- a/jedi/evaluate/pep0484.py +++ b/jedi/evaluate/pep0484.py @@ -89,7 +89,11 @@ def _split_mypy_param_declaration(decl_text): ['foo', 'Bar[baz, biz]']. """ - node = parse(decl_text).children[0] + try: + node = parse(decl_text, error_recovery=False).children[0] + except ParserSyntaxError: + debug.warning('Comment annotation is not valid Python: %s' % decl_text) + return [] if node.type == 'name': return [node.get_code().strip()] diff --git a/test/completion/pep0484_comments.py b/test/completion/pep0484_comments.py index 87021155..181b698a 100644 --- a/test/completion/pep0484_comments.py +++ b/test/completion/pep0484_comments.py @@ -157,6 +157,11 @@ x = UNKNOWN_NAME2 # type: str #? str() x +def x(a, b): + # type: ([) -> a + #? + a + class Cat(object): def __init__(self, age, friends, name): # type: (int, List[Dog], str) -> None