mirror of
https://github.com/davidhalter/jedi.git
synced 2026-01-09 21:42:20 +08:00
catch error in certain non-pep0484 annotations
This commit is contained in:
@@ -29,7 +29,10 @@ def _evaluate_for_annotation(evaluator, annotation):
|
||||
if (isinstance(definition, CompiledObject) and
|
||||
isinstance(definition.obj, str)):
|
||||
p = Parser(load_grammar(), definition.obj)
|
||||
element = p.module.children[0].children[0]
|
||||
try:
|
||||
element = p.module.children[0].children[0]
|
||||
except (AttributeError, IndexError):
|
||||
continue
|
||||
element.parent = annotation.parent
|
||||
definitions |= evaluator.eval_element(element)
|
||||
else:
|
||||
|
||||
@@ -114,14 +114,23 @@ SelfReference().test_method()
|
||||
def function_with_non_pep_0484_annotation(
|
||||
x: "I can put anything here",
|
||||
xx: "",
|
||||
yy: "\r\n;+*&^564835(---^&*34",
|
||||
y: 3 + 3) -> int("42"):
|
||||
yy: "\r\n\0;+*&^564835(---^&*34",
|
||||
y: 3 + 3,
|
||||
zz: float) -> int("42"):
|
||||
# infers int from function call
|
||||
#? int()
|
||||
x
|
||||
# infers int from function call
|
||||
#? int()
|
||||
xx
|
||||
# infers int from function call
|
||||
#? int()
|
||||
yy
|
||||
# infers str from function call
|
||||
#? str()
|
||||
y
|
||||
#? float()
|
||||
zz
|
||||
#?
|
||||
function_with_non_pep_0484_annotation(1, 2, 3, "force string")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user