make _remove_statements smaller
This commit is contained in:
1 parent
821d2b9220
commit
66ec389f5c
1 file changed
+11
-12
+11
-12
@@ -158,8 +158,17 @@ class NameFinder(object):
|
||||
typ = name.parent
|
||||
if typ.isinstance(pr.ForFlow):
|
||||
types += self._handle_for_loops(typ)
|
||||
else:
|
||||
elif typ.isinstance(pr.Statement):
|
||||
types += self._remove_statements(typ, resolve_decorator)
|
||||
else:
|
||||
r = typ
|
||||
if isinstance(r, pr.Class):
|
||||
r = er.Class(self._evaluator, r)
|
||||
elif isinstance(r, pr.Function):
|
||||
r = er.Function(self._evaluator, r)
|
||||
if r.isinstance(er.Function) and resolve_decorator:
|
||||
r = r.get_decorated_func()
|
||||
types.append(r)
|
||||
return types
|
||||
|
||||
def _remove_statements(self, r, resolve_decorator=False):
|
||||
@@ -171,7 +180,6 @@ class NameFinder(object):
|
||||
"""
|
||||
evaluator = self._evaluator
|
||||
res_new = []
|
||||
if r.isinstance(pr.Statement):
|
||||
add = []
|
||||
check_instance = None
|
||||
if isinstance(r, er.InstanceElement) and r.is_class_var:
|
||||
@@ -247,17 +255,8 @@ class NameFinder(object):
|
||||
add = [er.InstanceElement(evaluator, check_instance, a, True)
|
||||
if isinstance(a, (er.Function, pr.Function))
|
||||
else a for a in add]
|
||||
res_new += add
|
||||
else:
|
||||
if isinstance(r, pr.Class):
|
||||
r = er.Class(self._evaluator, r)
|
||||
elif isinstance(r, pr.Function):
|
||||
r = er.Function(self._evaluator, r)
|
||||
if r.isinstance(er.Function) and resolve_decorator:
|
||||
r = r.get_decorated_func()
|
||||
res_new.append(r)
|
||||
|
||||
return res_new
|
||||
return res_new + add
|
||||
|
||||
def _handle_for_loops(self, loop):
|
||||
# Take the first statement (for has always only
|
||||
|
||||
Reference in new issue
Block a user