mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-18 06:19:39 +08:00
Add a execute_annotation option to infer_annotation
This commit is contained in:
+6
-2
@@ -664,9 +664,13 @@ class ParamDefinition(Definition):
|
||||
def infer_default(self):
|
||||
return [Definition(self._evaluator, d.name) for d in self._name.infer_default()]
|
||||
|
||||
def infer_annotation(self):
|
||||
def infer_annotation(self, **kwargs):
|
||||
"""
|
||||
:param execute_annotation: If False, the values are not executed and
|
||||
you get classes instead of instances.
|
||||
"""
|
||||
return [Definition(self._evaluator, d.name)
|
||||
for d in self._name.infer_annotation().execute_annotation()]
|
||||
for d in self._name.infer_annotation(**kwargs)]
|
||||
|
||||
def to_string(self):
|
||||
return self._name.to_string()
|
||||
|
||||
@@ -220,11 +220,14 @@ class ParamName(BaseTreeParamName):
|
||||
def annotation_node(self):
|
||||
return self._get_param_node().annotation
|
||||
|
||||
def infer_annotation(self):
|
||||
def infer_annotation(self, execute_annotation=True):
|
||||
node = self.annotation_node
|
||||
if node is None:
|
||||
return NO_CONTEXTS
|
||||
return self.parent_context.parent_context.eval_node(node)
|
||||
contexts = self.parent_context.parent_context.eval_node(node)
|
||||
if execute_annotation:
|
||||
contexts = contexts.execute_annotation()
|
||||
return contexts
|
||||
|
||||
def infer_default(self):
|
||||
node = self.default_node
|
||||
|
||||
Reference in New Issue
Block a user