Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_children(self):
if self._children is None:
walker = _SuiteWalker(self)
for child in self.child_nodes:
ast.walk(child, walker)
self._children = walker.suites
return self._children
def _create_info_collector(self):
zero = self.info.scope.get_start() - 1
start_line = self.info.region_lines[0] - zero
end_line = self.info.region_lines[1] - zero
info_collector = _FunctionInformationCollector(start_line, end_line,
self.info.global_)
body = self.info.source[self.info.scope_region[0]:
self.info.scope_region[1]]
node = _parse_text(body)
ast.walk(node, info_collector)
return info_collector
def _get_unbound_names(self, defined_pyobject):
visitor = _GlobalUnboundNameFinder(self.pymodule, defined_pyobject)
ast.walk(self.pymodule.get_ast(), visitor)
return visitor.unbound
def _excepthandler(self, node):
if node.name is not None and isinstance(node.name, ast.Name):
type_node = node.type
if isinstance(node.type, ast.Tuple) and type_node.elts:
type_node = type_node.elts[0]
self._update_evaluated(node.name, type_node, eval_type=True)
for child in node.body:
ast.walk(child, self)
def _visit_function(self):
if self.names is None:
new_visitor = self.visitor(self.pycore, self.pyobject)
for n in ast.get_child_nodes(self.pyobject.get_ast()):
ast.walk(n, new_visitor)
self.names = new_visitor.names
self.names.update(self.pyobject.get_parameters())
self.returned_asts = new_visitor.returned_asts
self.is_generator = new_visitor.generator
self.defineds = new_visitor.defineds
def _For(self, node):
self.conditional = True
try:
# iter has to be checked before the target variables
ast.walk(node.iter, self)
ast.walk(node.target, self)
for child in node.body:
ast.walk(child, self)
for child in node.orelse:
ast.walk(child, self)
finally:
self.conditional = False
def _Tuple(self, node):
if not isinstance(node.ctx, ast.Store):
return
for child in ast.get_child_nodes(node):
ast.walk(child, self)
def _handle_conditional_node(self, node):
self.conditional = True
try:
for child in ast.get_child_nodes(node):
ast.walk(child, self)
finally:
self.conditional = False
def _handle_conditional_node(self, node):
self.conditional = True
try:
for child in ast.get_child_nodes(node):
ast.walk(child, self)
finally:
self.conditional = False
def loop_encountered(self, node):
self.loop_count += 1
for child in node.body:
ast.walk(child, self)
self.loop_count -= 1
if node.orelse:
ast.walk(node.orelse, self)