diff --git a/jedi/evaluate/__init__.py b/jedi/evaluate/__init__.py index 735c6596..0e110e3d 100644 --- a/jedi/evaluate/__init__.py +++ b/jedi/evaluate/__init__.py @@ -270,8 +270,8 @@ class Evaluator(object): if element.value in ('False', 'True', 'None'): types.add(compiled.builtin_from_name(self, element.value)) # else: print e.g. could be evaluated like this in Python 2.7 - elif element.isinstance(tree.Lambda): - types = set([er.LambdaWrapper(self, element)]) + elif isinstance(element, tree.Lambda): + types = set([er.LambdaWrapper(self, context, element)]) elif element.isinstance(er.LambdaWrapper): types = set([element]) # TODO this is no real evaluation. elif element.type == 'expr_stmt': diff --git a/jedi/evaluate/dynamic.py b/jedi/evaluate/dynamic.py index 2c7beeb4..6458168f 100644 --- a/jedi/evaluate/dynamic.py +++ b/jedi/evaluate/dynamic.py @@ -104,21 +104,22 @@ def _search_function_executions(evaluator, module_context, funcdef): from jedi.evaluate import representation as er def get_possible_nodes(module_context, func_name): - try: - names = module_context.module_node.used_names[func_name] - except KeyError: - return + if not isinstance(module_context, er.ModuleContext): + return + try: + names = module_context.module_node.used_names[func_name] + except KeyError: + return - for name in names: - bracket = name.get_next_leaf() - trailer = bracket.parent - if trailer.type == 'trailer' and bracket == '(': - yield name, trailer + for name in names: + bracket = name.get_next_leaf() + trailer = bracket.parent + if trailer.type == 'trailer' and bracket == '(': + yield name, trailer func_name = unicode(funcdef.name) compare_node = funcdef if func_name == '__init__': - raise NotImplementedError cls = funcdef.get_parent_scope() if isinstance(cls, tree.Class): func_name = unicode(cls.name) diff --git a/jedi/evaluate/helpers.py b/jedi/evaluate/helpers.py index 77e6d2fa..8694d586 100644 --- a/jedi/evaluate/helpers.py +++ b/jedi/evaluate/helpers.py @@ -64,6 +64,7 @@ def deep_ast_copy(obj, parent=None, new_elements=None): if parent is not None: new_obj.parent = parent + raise NotImplementedError return new_obj @@ -94,12 +95,14 @@ def call_of_leaf(leaf, cut_own_trailer=False): power = trailer.parent index = power.children.index(trailer) - power = deep_ast_copy(power) if cut_own_trailer: cut = index else: cut = index + 1 - power.children[cut:] = [] + + new_power = copy.copy(power) + new_power.children = list(new_power.children) + new_power.children[cut:] = [] if power.type == 'error_node': start = index diff --git a/jedi/evaluate/instance.py b/jedi/evaluate/instance.py index 3dcab48c..a9dbebe4 100644 --- a/jedi/evaluate/instance.py +++ b/jedi/evaluate/instance.py @@ -375,7 +375,12 @@ class ParamArguments(object): self._class_context, self._funcdef ) + is_first = True for p in params: + # TODO Yeah, here at last, the class seems to be really wrong. + if is_first: + is_first = False + continue yield None, self.LazyParamContext(p) diff --git a/jedi/evaluate/iterable.py b/jedi/evaluate/iterable.py index 6c50af43..9c679e49 100644 --- a/jedi/evaluate/iterable.py +++ b/jedi/evaluate/iterable.py @@ -209,6 +209,7 @@ class Comprehension(AbstractSequence): # InstanceElement anyway, I don't care. node = node.var last_comp = list(comp_for.get_comp_fors())[-1] + raise NotImplementedError('should not need to copy...') return helpers.deep_ast_copy(node, parent=last_comp) def _nested(self, comp_fors): diff --git a/jedi/evaluate/representation.py b/jedi/evaluate/representation.py index 9b8096f9..fa64f3a2 100644 --- a/jedi/evaluate/representation.py +++ b/jedi/evaluate/representation.py @@ -598,8 +598,7 @@ class FunctionContext(use_metaclass(CachedMetaClass, context.TreeContext, Wrappe class LambdaWrapper(FunctionContext): - def get_decorated_func(self): - return self + pass class FunctionExecutionContext(Executed): @@ -638,8 +637,8 @@ class FunctionExecutionContext(Executed): @recursion.execution_recursion_decorator def get_return_values(self, check_yields=False): funcdef = self.funcdef - if funcdef.type in ('lambdef', 'lambdef_nocond'): - return self.evaluator.eval_element(self.children[-1]) + if isinstance(funcdef, tree.Lambda): + return self.evaluator.eval_element(self, funcdef.children[-1]) """ if func.listeners: @@ -821,7 +820,7 @@ class ModuleContext(use_metaclass(CachedMetaClass, context.TreeContext, Wrapper) name = i.star_import_name() new = imports.ImportWrapper(self, name).follow() for module in new: - if isinstance(module, tree.Module): + if isinstance(module, ModuleContext): modules += module.star_imports() modules += new return modules