diff --git a/jedi/evaluate/docstrings.py b/jedi/evaluate/docstrings.py index 9a51671a..e63745e5 100644 --- a/jedi/evaluate/docstrings.py +++ b/jedi/evaluate/docstrings.py @@ -191,7 +191,7 @@ def follow_param(module_context, param): [p for param_str in _search_param_in_docstr(docstring, str(param.name)) for p in _evaluate_for_statement_string(module_context, param_str)] ) - func = param.parent_function + func = param.get_parent_function() types = eval_docstring(func.raw_doc) if func.name.value == '__init__': cls = search_ancestor(func, 'classdef') diff --git a/jedi/evaluate/finder.py b/jedi/evaluate/finder.py index 76687d7d..82e75948 100644 --- a/jedi/evaluate/finder.py +++ b/jedi/evaluate/finder.py @@ -98,7 +98,7 @@ class NameFinder(object): if self._context.predefined_names: # TODO is this ok? node might not always be a tree.Name node = self._name - while node is not None and not isinstance(node, tree.IsScope): + while node is not None and not node.is_scope(): node = node.parent if node.type in ("if_stmt", "for_stmt", "comp_for"): try: diff --git a/jedi/parser/tree.py b/jedi/parser/tree.py index ba2470e4..2a961a51 100644 --- a/jedi/parser/tree.py +++ b/jedi/parser/tree.py @@ -711,15 +711,6 @@ class ErrorLeaf(LeafWithNewLines): (type(self).__name__, self.original_type, repr(self.value), self.start_pos) -class IsScopeMeta(type): - def __instancecheck__(self, other): - return other.is_scope() - - -class IsScope(use_metaclass(IsScopeMeta)): - pass - - class Scope(BaseNode, DocstringMixin): """ Super class for the parser tree, which represents the state of a python @@ -1635,9 +1626,8 @@ class Param(BaseNode): def position_nr(self): return self.parent.children.index(self) - 1 - @property - def parent_function(self): - return self.get_parent_until(IsScope) + def get_parent_function(self): + return search_ancestor(self, ('funcdef', 'lambda')) def __repr__(self): default = '' if self.default is None else '=%s' % self.default.get_code()