Decorators#

class astroid.nodes.Decorators(lineno: int | None, col_offset: int | None, parent: NodeNG | None, *, end_lineno: int | None, end_col_offset: int | None)[source]#

Bases: NodeNG

A node representing a list of decorators.

A Decorators is the decorators that are applied to a method or function.

>>> import astroid
>>> node = astroid.extract_node('''
@property
def my_property(self):
    return 3
''')
>>> node
<FunctionDef.my_property l.2 at 0x7f23b2e35d30>
>>> list(node.get_children())[0]
<Decorators l.1 at 0x7f23b2e35d68>
get_children()[source]#

Get the child nodes below this node.

nodes: list[NodeNG]#

The decorators that this node contains.

postinit(nodes: list[NodeNG]) None[source]#
scope() LocalsDictNodeNG[source]#

The first parent node defining a new scope. These can be Module, FunctionDef, ClassDef, Lambda, or GeneratorExp nodes.

Returns:

The first parent scope node.