Exemplo n.º 1
0
 def visit_decorators(self, node, parent):
     """visit a Decorators node by returning a fresh instance of it"""
     # /!\ node is actually a _ast.FunctionDef node while
     # parent is an astroid.nodes.FunctionDef node
     newnode = nodes.Decorators(node.lineno, node.col_offset, parent)
     newnode.postinit([self.visit(child, newnode) for child in node.decorator_list])
     return newnode
Exemplo n.º 2
0
 def visit_decorators(self, node, parent, assign_ctx=None):
     """visit a Decorators node by returning a fresh instance of it"""
     # /!\ node is actually a _ast.Function node while
     # parent is a astroid.nodes.Function node
     newnode = new.Decorators()
     _lineno_parent(node, newnode, parent)
     decorators = node.decorator_list
     newnode.nodes = [self.visit(child, newnode, assign_ctx)
                      for child in decorators]
     return newnode
Exemplo n.º 3
0
 def visit_decorators(self, node, parent):
     """visit a Decorators node by returning a fresh instance of it"""
     # /!\ node is actually a _ast.Function node while
     # parent is a astroid.nodes.Function node
     newnode = new.Decorators()
     _lineno_parent(node, newnode, parent)
     if 'decorators' in node._fields: # py < 2.6, i.e. 2.5
         decorators = node.decorators
     else:
         decorators = node.decorator_list
     newnode.nodes = [self.visit(child, newnode) for child in decorators]
     return newnode
Exemplo n.º 4
0
 def visit_decorators(self, node, parent):
     """visit a Decorators node by returning a fresh instance of it"""
     # /!\ node is actually an _ast.FunctionDef node while
     # parent is an astroid.nodes.FunctionDef node
     if PY38:
         # Set the line number of the first decorator for Python 3.8+.
         lineno = node.decorator_list[0].lineno
     else:
         lineno = node.lineno
     newnode = nodes.Decorators(lineno, node.col_offset, parent)
     newnode.postinit([self.visit(child, newnode) for child in node.decorator_list])
     return newnode