diff --git a/jedi/evaluate.py b/jedi/evaluate.py index f768adcf..73d88562 100644 --- a/jedi/evaluate.py +++ b/jedi/evaluate.py @@ -829,7 +829,7 @@ class Array(use_metaclass(cache.CachedMetaClass, parsing.Base)): return builtin.Builtin.scope def __getattr__(self, name): - if name not in ['type', 'start_pos']: + if name not in ['type', 'start_pos', 'get_only_subelement']: raise AttributeError('Strange access: %s.' % name) return getattr(self._array, name) @@ -1373,9 +1373,11 @@ def follow_call_list(call_list): # comprehensions result += follow_statement(stmt) else: + if isinstance(call, (parsing.Lambda)): + result.append(Function(call)) # With things like params, these can also be functions... - if isinstance(call, (parsing.Lambda, Function, Class, - Instance, dynamic.ArrayInstance)): + elif isinstance(call, (Function, Class, Instance, + dynamic.ArrayInstance)): result.append(call) # The string tokens are just operations (+, -, etc.) elif not isinstance(call, (str, unicode)): diff --git a/jedi/parsing.py b/jedi/parsing.py index f553f238..c3e8cd42 100644 --- a/jedi/parsing.py +++ b/jedi/parsing.py @@ -445,6 +445,10 @@ class Lambda(Function): string = "lambda %s:" % params return string + super(Function, self).get_code(indention=indention) + def __repr__(self): + return "<%s @%s (%s-%s)>" % (type(self).__name__, self.start_pos[0], + self.start_pos[1], self.end_pos[1]) + class Flow(Scope): """ @@ -1551,6 +1555,7 @@ class PyFuzzyParser(object): if ret is not None: ret.parent = lambd lambd.returns.append(ret) + lambd.end_pos = ret.end_pos lambd.parent = self.scope tok_list[-1] = lambd continue diff --git a/test/completion/functions.py b/test/completion/functions.py index 421a34b4..24e3e0e5 100644 --- a/test/completion/functions.py +++ b/test/completion/functions.py @@ -373,11 +373,11 @@ a(0) arg_l = lambda x, y: y, x #? float() -argl[0]('', 1.0) +arg_l[0]('', 1.0) #? list() arg_l[1] -arg_l = lambda x, y: y, x +arg_l = lambda x, y: (y, x) args = 1,"" result = arg_l(*args) #? tuple() @@ -395,9 +395,11 @@ with_lambda(arg_l, 1.0)[1] #? float() with_lambda(arg_l, 1.0)[0] #? float() -with_lambda(arg_l, x=1.0)[0] +with_lambda(arg_l, y=1.0)[0] +#? int() +with_lambda(lambda x: x) #? float() -with_lambda(lambda x: x, x=1.0)[0] +with_lambda(lambda x, y: y, y=1.0) arg_func = lambda *args, **kwargs: args[0], kwargs['a'] #? int()