mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 06:24:27 +08:00
changed get_parent_until method
This commit is contained in:
10
parsing.py
10
parsing.py
@@ -99,10 +99,14 @@ class Simple(Base):
|
||||
self.parent = lambda: None
|
||||
|
||||
@Python3Method
|
||||
def get_parent_until(self, *classes):
|
||||
def get_parent_until(self, classes=(), reverse=False):
|
||||
""" Takes always the parent, until one class (not a Class) """
|
||||
if type(classes) != tuple:
|
||||
classes = (classes,)
|
||||
scope = self
|
||||
while not (scope.parent() is None or scope.isinstance(*classes)):
|
||||
while not scope.parent() is None:
|
||||
if reverse != scope.isinstance(*classes):
|
||||
break
|
||||
scope = scope.parent()
|
||||
return scope
|
||||
|
||||
@@ -455,7 +459,7 @@ class Flow(Scope):
|
||||
n += super(Flow, self).get_set_vars()
|
||||
return n
|
||||
else:
|
||||
return self.get_parent_until(Class, Function).get_set_vars()
|
||||
return self.get_parent_until((Class, Function)).get_set_vars()
|
||||
|
||||
def get_imports(self):
|
||||
i = super(Flow, self).get_imports()
|
||||
|
||||
Reference in New Issue
Block a user