mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
Catch parser errors instead of error recovery when splitting param comments
This commit is contained in:
@@ -89,7 +89,11 @@ def _split_mypy_param_declaration(decl_text):
|
|||||||
['foo', 'Bar[baz, biz]'].
|
['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':
|
if node.type == 'name':
|
||||||
return [node.get_code().strip()]
|
return [node.get_code().strip()]
|
||||||
|
|||||||
@@ -157,6 +157,11 @@ x = UNKNOWN_NAME2 # type: str
|
|||||||
#? str()
|
#? str()
|
||||||
x
|
x
|
||||||
|
|
||||||
|
def x(a, b):
|
||||||
|
# type: ([) -> a
|
||||||
|
#?
|
||||||
|
a
|
||||||
|
|
||||||
class Cat(object):
|
class Cat(object):
|
||||||
def __init__(self, age, friends, name):
|
def __init__(self, age, friends, name):
|
||||||
# type: (int, List[Dog], str) -> None
|
# type: (int, List[Dog], str) -> None
|
||||||
|
|||||||
Reference in New Issue
Block a user