Skip to content

Node

🛈 DocStrings

Represents a node in the Python code structure tree.

A node contains information about a specific code element (like a class or function) and maintains relationships with its child nodes.

Parameters:

Name Type Description Default
name str

The identifier of the code element

required
type NodeType

The classification of the code element

required
children list[Node]

List of child nodes

required
line_number int

Source code line where this element appears

required
decorators list[str]

List of decorator names applied to this element

required
Source code in src/jinjarope/codetree.py
@dataclass
class Node:
    """Represents a node in the Python code structure tree.

    A node contains information about a specific code element (like a class
    or function) and maintains relationships with its child nodes.

    Args:
        name: The identifier of the code element
        type: The classification of the code element
        children: List of child nodes
        line_number: Source code line where this element appears
        decorators: List of decorator names applied to this element
    """

    name: str
    type: NodeType
    children: list[Node]
    line_number: int
    decorators: list[str]

:fa-brands-github: Show source on GitHub