forked from VimPlug/jedi
The Lambda type should be lambdef, not lambda. Use the grammar types.
This commit is contained in:
@@ -280,7 +280,7 @@ class Evaluator(object):
|
|||||||
if element.value in ('False', 'True', 'None'):
|
if element.value in ('False', 'True', 'None'):
|
||||||
types.add(compiled.builtin_from_name(self, element.value))
|
types.add(compiled.builtin_from_name(self, element.value))
|
||||||
# else: print e.g. could be evaluated like this in Python 2.7
|
# else: print e.g. could be evaluated like this in Python 2.7
|
||||||
elif typ == 'lambda':
|
elif typ == 'lambdef':
|
||||||
types = set([er.FunctionContext(self, context, element)])
|
types = set([er.FunctionContext(self, context, element)])
|
||||||
elif typ == 'expr_stmt':
|
elif typ == 'expr_stmt':
|
||||||
types = self.eval_statement(context, element)
|
types = self.eval_statement(context, element)
|
||||||
@@ -337,7 +337,7 @@ class Evaluator(object):
|
|||||||
# This is the first global lookup.
|
# This is the first global lookup.
|
||||||
stmt = atom.get_definition()
|
stmt = atom.get_definition()
|
||||||
if stmt.type == 'comp_for':
|
if stmt.type == 'comp_for':
|
||||||
stmt = tree.search_ancestor(stmt, ('expr_stmt', 'lambda', 'funcdef', 'classdef'))
|
stmt = tree.search_ancestor(stmt, ('expr_stmt', 'lambdef', 'funcdef', 'classdef'))
|
||||||
if stmt is None or stmt.type != 'expr_stmt':
|
if stmt is None or stmt.type != 'expr_stmt':
|
||||||
# We only need to adjust the start_pos for statements, because
|
# We only need to adjust the start_pos for statements, because
|
||||||
# there the name cannot be used.
|
# there the name cannot be used.
|
||||||
@@ -551,7 +551,7 @@ class Evaluator(object):
|
|||||||
if scope_node == base_node:
|
if scope_node == base_node:
|
||||||
return base_context
|
return base_context
|
||||||
|
|
||||||
is_funcdef = scope_node.type in ('funcdef', 'lambda')
|
is_funcdef = scope_node.type in ('funcdef', 'lambdef')
|
||||||
parent_scope = scope_node.get_parent_scope()
|
parent_scope = scope_node.get_parent_scope()
|
||||||
parent_context = from_scope_node(parent_scope, child_is_funcdef=is_funcdef)
|
parent_context = from_scope_node(parent_scope, child_is_funcdef=is_funcdef)
|
||||||
|
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ def follow_param(module_context, param):
|
|||||||
for p in _evaluate_for_statement_string(module_context, param_str)]
|
for p in _evaluate_for_statement_string(module_context, param_str)]
|
||||||
)
|
)
|
||||||
func = param.get_parent_function()
|
func = param.get_parent_function()
|
||||||
if func.type == 'lambda':
|
if func.type == 'lambdef':
|
||||||
return set()
|
return set()
|
||||||
|
|
||||||
types = eval_docstring(func.raw_doc)
|
types = eval_docstring(func.raw_doc)
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ class FunctionContext(use_metaclass(CachedMetaClass, context.TreeContext)):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
if self.tree_node.type == 'lambda':
|
if self.tree_node.type == 'lambdef':
|
||||||
return LambdaName(self)
|
return LambdaName(self)
|
||||||
return ContextName(self, self.tree_node.name)
|
return ContextName(self, self.tree_node.name)
|
||||||
|
|
||||||
@@ -320,7 +320,7 @@ class FunctionExecutionContext(context.TreeContext):
|
|||||||
@recursion.execution_recursion_decorator()
|
@recursion.execution_recursion_decorator()
|
||||||
def get_return_values(self, check_yields=False):
|
def get_return_values(self, check_yields=False):
|
||||||
funcdef = self.tree_node
|
funcdef = self.tree_node
|
||||||
if funcdef.type == 'lambda':
|
if funcdef.type == 'lambdef':
|
||||||
return self.evaluator.eval_element(self, funcdef.children[-1])
|
return self.evaluator.eval_element(self, funcdef.children[-1])
|
||||||
|
|
||||||
if check_yields:
|
if check_yields:
|
||||||
|
|||||||
@@ -634,7 +634,7 @@ class Lambda(Function):
|
|||||||
-2) <Operator: :>
|
-2) <Operator: :>
|
||||||
-1) Node() representing body
|
-1) Node() representing body
|
||||||
"""
|
"""
|
||||||
type = 'lambda'
|
type = 'lambdef'
|
||||||
__slots__ = ()
|
__slots__ = ()
|
||||||
|
|
||||||
def __init__(self, children):
|
def __init__(self, children):
|
||||||
@@ -1084,7 +1084,7 @@ class Param(PythonBaseNode):
|
|||||||
return index - 1
|
return index - 1
|
||||||
|
|
||||||
def get_parent_function(self):
|
def get_parent_function(self):
|
||||||
return search_ancestor(self, ('funcdef', 'lambda'))
|
return search_ancestor(self, ('funcdef', 'lambdef'))
|
||||||
|
|
||||||
def get_description(self):
|
def get_description(self):
|
||||||
# TODO Remove?
|
# TODO Remove?
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class TestsFunctionAndLambdaParsing(object):
|
|||||||
return request.keywords['expected']
|
return request.keywords['expected']
|
||||||
|
|
||||||
def test_name(self, node, expected):
|
def test_name(self, node, expected):
|
||||||
if node.type != 'lambda':
|
if node.type != 'lambdef':
|
||||||
assert isinstance(node.name, tree.Name)
|
assert isinstance(node.name, tree.Name)
|
||||||
assert unicode(node.name) == u(expected['name'])
|
assert unicode(node.name) == u(expected['name'])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user