---
source: crates/ruff_python_parser/tests/fixtures.rs
input_file: crates/ruff_python_parser/resources/valid/statement/if.py
---
## AST

```
Module(
    ModModule {
        node_index: AtomicNodeIndex(..),
        range: 0..375,
        body: [
            If(
                StmtIf {
                    node_index: AtomicNodeIndex(..),
                    range: 0..28,
                    test: NumberLiteral(
                        ExprNumberLiteral {
                            node_index: AtomicNodeIndex(..),
                            range: 3..4,
                            value: Int(
                                1,
                            ),
                        },
                    ),
                    body: [
                        Expr(
                            StmtExpr {
                                node_index: AtomicNodeIndex(..),
                                range: 6..8,
                                value: NumberLiteral(
                                    ExprNumberLiteral {
                                        node_index: AtomicNodeIndex(..),
                                        range: 6..8,
                                        value: Int(
                                            10,
                                        ),
                                    },
                                ),
                            },
                        ),
                    ],
                    elif_else_clauses: [
                        ElifElseClause {
                            range: 9..19,
                            node_index: AtomicNodeIndex(..),
                            test: Some(
                                NumberLiteral(
                                    ExprNumberLiteral {
                                        node_index: AtomicNodeIndex(..),
                                        range: 14..15,
                                        value: Int(
                                            2,
                                        ),
                                    },
                                ),
                            ),
                            body: [
                                Expr(
                                    StmtExpr {
                                        node_index: AtomicNodeIndex(..),
                                        range: 17..19,
                                        value: NumberLiteral(
                                            ExprNumberLiteral {
                                                node_index: AtomicNodeIndex(..),
                                                range: 17..19,
                                                value: Int(
                                                    20,
                                                ),
                                            },
                                        ),
                                    },
                                ),
                            ],
                        },
                        ElifElseClause {
                            range: 20..28,
                            node_index: AtomicNodeIndex(..),
                            test: None,
                            body: [
                                Expr(
                                    StmtExpr {
                                        node_index: AtomicNodeIndex(..),
                                        range: 26..28,
                                        value: NumberLiteral(
                                            ExprNumberLiteral {
                                                node_index: AtomicNodeIndex(..),
                                                range: 26..28,
                                                value: Int(
                                                    30,
                                                ),
                                            },
                                        ),
                                    },
                                ),
                            ],
                        },
                    ],
                },
            ),
            If(
                StmtIf {
                    node_index: AtomicNodeIndex(..),
                    range: 30..52,
                    test: BooleanLiteral(
                        ExprBooleanLiteral {
                            node_index: AtomicNodeIndex(..),
                            range: 33..37,
                            value: true,
                        },
                    ),
                    body: [
                        Expr(
                            StmtExpr {
                                node_index: AtomicNodeIndex(..),
                                range: 43..44,
                                value: NumberLiteral(
                                    ExprNumberLiteral {
                                        node_index: AtomicNodeIndex(..),
                                        range: 43..44,
                                        value: Int(
                                            1,
                                        ),
                                    },
                                ),
                            },
                        ),
                        Expr(
                            StmtExpr {
                                node_index: AtomicNodeIndex(..),
                                range: 49..52,
                                value: EllipsisLiteral(
                                    ExprEllipsisLiteral {
                                        node_index: AtomicNodeIndex(..),
                                        range: 49..52,
                                    },
                                ),
                            },
                        ),
                    ],
                    elif_else_clauses: [],
                },
            ),
            If(
                StmtIf {
                    node_index: AtomicNodeIndex(..),
                    range: 53..85,
                    test: Compare(
                        ExprCompare {
                            node_index: AtomicNodeIndex(..),
                            range: 56..61,
                            left: Name(
                                ExprName {
                                    node_index: AtomicNodeIndex(..),
                                    range: 56..57,
                                    id: Name("x"),
                                    ctx: Load,
                                },
                            ),
                            ops: [
                                Lt,
                            ],
                            comparators: [
                                NumberLiteral(
                                    ExprNumberLiteral {
                                        node_index: AtomicNodeIndex(..),
                                        range: 60..61,
                                        value: Int(
                                            1,
                                        ),
                                    },
                                ),
                            ],
                        },
                    ),
                    body: [
                        Expr(
                            StmtExpr {
                                node_index: AtomicNodeIndex(..),
                                range: 67..70,
                                value: EllipsisLiteral(
                                    ExprEllipsisLiteral {
                                        node_index: AtomicNodeIndex(..),
                                        range: 67..70,
                                    },
                                ),
                            },
                        ),
                    ],
                    elif_else_clauses: [
                        ElifElseClause {
                            range: 71..85,
                            node_index: AtomicNodeIndex(..),
                            test: None,
                            body: [
                                Pass(
                                    StmtPass {
                                        node_index: AtomicNodeIndex(..),
                                        range: 81..85,
                                    },
                                ),
                            ],
                        },
                    ],
                },
            ),
            If(
                StmtIf {
                    node_index: AtomicNodeIndex(..),
                    range: 87..117,
                    test: Name(
                        ExprName {
                            node_index: AtomicNodeIndex(..),
                            range: 90..91,
                            id: Name("a"),
                            ctx: Load,
                        },
                    ),
                    body: [
                        Pass(
                            StmtPass {
                                node_index: AtomicNodeIndex(..),
                                range: 97..101,
                            },
                        ),
                    ],
                    elif_else_clauses: [
                        ElifElseClause {
                            range: 102..117,
                            node_index: AtomicNodeIndex(..),
                            test: Some(
                                Name(
                                    ExprName {
                                        node_index: AtomicNodeIndex(..),
                                        range: 107..108,
                                        id: Name("b"),
                                        ctx: Load,
                                    },
                                ),
                            ),
                            body: [
                                Expr(
                                    StmtExpr {
                                        node_index: AtomicNodeIndex(..),
                                        range: 114..117,
                                        value: EllipsisLiteral(
                                            ExprEllipsisLiteral {
                                                node_index: AtomicNodeIndex(..),
                                                range: 114..117,
                                            },
                                        ),
                                    },
                                ),
                            ],
                        },
                    ],
                },
            ),
            If(
                StmtIf {
                    node_index: AtomicNodeIndex(..),
                    range: 119..203,
                    test: BoolOp(
                        ExprBoolOp {
                            node_index: AtomicNodeIndex(..),
                            range: 122..129,
                            op: And,
                            values: [
                                Name(
                                    ExprName {
                                        node_index: AtomicNodeIndex(..),
                                        range: 122..123,
                                        id: Name("a"),
                                        ctx: Load,
                                    },
                                ),
                                Name(
                                    ExprName {
                                        node_index: AtomicNodeIndex(..),
                                        range: 128..129,
                                        id: Name("b"),
                                        ctx: Load,
                                    },
                                ),
                            ],
                        },
                    ),
                    body: [
                        Expr(
                            StmtExpr {
                                node_index: AtomicNodeIndex(..),
                                range: 135..138,
                                value: EllipsisLiteral(
                                    ExprEllipsisLiteral {
                                        node_index: AtomicNodeIndex(..),
                                        range: 135..138,
                                    },
                                ),
                            },
                        ),
                    ],
                    elif_else_clauses: [
                        ElifElseClause {
                            range: 139..157,
                            node_index: AtomicNodeIndex(..),
                            test: Some(
                                BooleanLiteral(
                                    ExprBooleanLiteral {
                                        node_index: AtomicNodeIndex(..),
                                        range: 144..148,
                                        value: true,
                                    },
                                ),
                            ),
                            body: [
                                Expr(
                                    StmtExpr {
                                        node_index: AtomicNodeIndex(..),
                                        range: 154..157,
                                        value: EllipsisLiteral(
                                            ExprEllipsisLiteral {
                                                node_index: AtomicNodeIndex(..),
                                                range: 154..157,
                                            },
                                        ),
                                    },
                                ),
                            ],
                        },
                        ElifElseClause {
                            range: 158..173,
                            node_index: AtomicNodeIndex(..),
                            test: Some(
                                Name(
                                    ExprName {
                                        node_index: AtomicNodeIndex(..),
                                        range: 163..164,
                                        id: Name("c"),
                                        ctx: Load,
                                    },
                                ),
                            ),
                            body: [
                                Expr(
                                    StmtExpr {
                                        node_index: AtomicNodeIndex(..),
                                        range: 170..173,
                                        value: EllipsisLiteral(
                                            ExprEllipsisLiteral {
                                                node_index: AtomicNodeIndex(..),
                                                range: 170..173,
                                            },
                                        ),
                                    },
                                ),
                            ],
                        },
                        ElifElseClause {
                            range: 174..189,
                            node_index: AtomicNodeIndex(..),
                            test: Some(
                                Name(
                                    ExprName {
                                        node_index: AtomicNodeIndex(..),
                                        range: 179..180,
                                        id: Name("d"),
                                        ctx: Load,
                                    },
                                ),
                            ),
                            body: [
                                Expr(
                                    StmtExpr {
                                        node_index: AtomicNodeIndex(..),
                                        range: 186..189,
                                        value: EllipsisLiteral(
                                            ExprEllipsisLiteral {
                                                node_index: AtomicNodeIndex(..),
                                                range: 186..189,
                                            },
                                        ),
                                    },
                                ),
                            ],
                        },
                        ElifElseClause {
                            range: 190..203,
                            node_index: AtomicNodeIndex(..),
                            test: None,
                            body: [
                                Expr(
                                    StmtExpr {
                                        node_index: AtomicNodeIndex(..),
                                        range: 200..203,
                                        value: Call(
                                            ExprCall {
                                                node_index: AtomicNodeIndex(..),
                                                range: 200..203,
                                                func: Name(
                                                    ExprName {
                                                        node_index: AtomicNodeIndex(..),
                                                        range: 200..201,
                                                        id: Name("f"),
                                                        ctx: Load,
                                                    },
                                                ),
                                                arguments: Arguments {
                                                    range: 201..203,
                                                    node_index: AtomicNodeIndex(..),
                                                    args: [],
                                                    keywords: [],
                                                },
                                            },
                                        ),
                                    },
                                ),
                            ],
                        },
                    ],
                },
            ),
            If(
                StmtIf {
                    node_index: AtomicNodeIndex(..),
                    range: 229..260,
                    test: Named(
                        ExprNamed {
                            node_index: AtomicNodeIndex(..),
                            range: 232..238,
                            target: Name(
                                ExprName {
                                    node_index: AtomicNodeIndex(..),
                                    range: 232..233,
                                    id: Name("a"),
                                    ctx: Store,
                                },
                            ),
                            value: Name(
                                ExprName {
                                    node_index: AtomicNodeIndex(..),
                                    range: 237..238,
                                    id: Name("b"),
                                    ctx: Load,
                                },
                            ),
                        },
                    ),
                    body: [
                        Expr(
                            StmtExpr {
                                node_index: AtomicNodeIndex(..),
                                range: 240..243,
                                value: EllipsisLiteral(
                                    ExprEllipsisLiteral {
                                        node_index: AtomicNodeIndex(..),
                                        range: 240..243,
                                    },
                                ),
                            },
                        ),
                    ],
                    elif_else_clauses: [
                        ElifElseClause {
                            range: 244..260,
                            node_index: AtomicNodeIndex(..),
                            test: Some(
                                Named(
                                    ExprNamed {
                                        node_index: AtomicNodeIndex(..),
                                        range: 249..255,
                                        target: Name(
                                            ExprName {
                                                node_index: AtomicNodeIndex(..),
                                                range: 249..250,
                                                id: Name("a"),
                                                ctx: Store,
                                            },
                                        ),
                                        value: Name(
                                            ExprName {
                                                node_index: AtomicNodeIndex(..),
                                                range: 254..255,
                                                id: Name("b"),
                                                ctx: Load,
                                            },
                                        ),
                                    },
                                ),
                            ),
                            body: [
                                Expr(
                                    StmtExpr {
                                        node_index: AtomicNodeIndex(..),
                                        range: 257..260,
                                        value: EllipsisLiteral(
                                            ExprEllipsisLiteral {
                                                node_index: AtomicNodeIndex(..),
                                                range: 257..260,
                                            },
                                        ),
                                    },
                                ),
                            ],
                        },
                    ],
                },
            ),
            If(
                StmtIf {
                    node_index: AtomicNodeIndex(..),
                    range: 261..302,
                    test: Lambda(
                        ExprLambda {
                            node_index: AtomicNodeIndex(..),
                            range: 264..275,
                            parameters: Some(
                                Parameters {
                                    range: 271..272,
                                    node_index: AtomicNodeIndex(
                                        0,
                                    ),
                                    posonlyargs: [],
                                    args: [
                                        ParameterWithDefault {
                                            range: 271..272,
                                            node_index: AtomicNodeIndex(..),
                                            parameter: Parameter {
                                                range: 271..272,
                                                node_index: AtomicNodeIndex(..),
                                                name: Identifier {
                                                    id: Name("x"),
                                                    range: 271..272,
                                                    node_index: AtomicNodeIndex(..),
                                                },
                                                annotation: None,
                                            },
                                            default: None,
                                        },
                                    ],
                                    vararg: None,
                                    kwonlyargs: [],
                                    kwarg: None,
                                },
                            ),
                            body: Name(
                                ExprName {
                                    node_index: AtomicNodeIndex(..),
                                    range: 274..275,
                                    id: Name("x"),
                                    ctx: Load,
                                },
                            ),
                        },
                    ),
                    body: [
                        Expr(
                            StmtExpr {
                                node_index: AtomicNodeIndex(..),
                                range: 277..280,
                                value: EllipsisLiteral(
                                    ExprEllipsisLiteral {
                                        node_index: AtomicNodeIndex(..),
                                        range: 277..280,
                                    },
                                ),
                            },
                        ),
                    ],
                    elif_else_clauses: [
                        ElifElseClause {
                            range: 281..302,
                            node_index: AtomicNodeIndex(..),
                            test: Some(
                                Lambda(
                                    ExprLambda {
                                        node_index: AtomicNodeIndex(..),
                                        range: 286..297,
                                        parameters: Some(
                                            Parameters {
                                                range: 293..294,
                                                node_index: AtomicNodeIndex(
                                                    0,
                                                ),
                                                posonlyargs: [],
                                                args: [
                                                    ParameterWithDefault {
                                                        range: 293..294,
                                                        node_index: AtomicNodeIndex(..),
                                                        parameter: Parameter {
                                                            range: 293..294,
                                                            node_index: AtomicNodeIndex(..),
                                                            name: Identifier {
                                                                id: Name("x"),
                                                                range: 293..294,
                                                                node_index: AtomicNodeIndex(..),
                                                            },
                                                            annotation: None,
                                                        },
                                                        default: None,
                                                    },
                                                ],
                                                vararg: None,
                                                kwonlyargs: [],
                                                kwarg: None,
                                            },
                                        ),
                                        body: Name(
                                            ExprName {
                                                node_index: AtomicNodeIndex(..),
                                                range: 296..297,
                                                id: Name("x"),
                                                ctx: Load,
                                            },
                                        ),
                                    },
                                ),
                            ),
                            body: [
                                Expr(
                                    StmtExpr {
                                        node_index: AtomicNodeIndex(..),
                                        range: 299..302,
                                        value: EllipsisLiteral(
                                            ExprEllipsisLiteral {
                                                node_index: AtomicNodeIndex(..),
                                                range: 299..302,
                                            },
                                        ),
                                    },
                                ),
                            ],
                        },
                    ],
                },
            ),
            If(
                StmtIf {
                    node_index: AtomicNodeIndex(..),
                    range: 303..336,
                    test: Await(
                        ExprAwait {
                            node_index: AtomicNodeIndex(..),
                            range: 306..313,
                            value: Name(
                                ExprName {
                                    node_index: AtomicNodeIndex(..),
                                    range: 312..313,
                                    id: Name("x"),
                                    ctx: Load,
                                },
                            ),
                        },
                    ),
                    body: [
                        Expr(
                            StmtExpr {
                                node_index: AtomicNodeIndex(..),
                                range: 315..318,
                                value: EllipsisLiteral(
                                    ExprEllipsisLiteral {
                                        node_index: AtomicNodeIndex(..),
                                        range: 315..318,
                                    },
                                ),
                            },
                        ),
                    ],
                    elif_else_clauses: [
                        ElifElseClause {
                            range: 319..336,
                            node_index: AtomicNodeIndex(..),
                            test: Some(
                                Await(
                                    ExprAwait {
                                        node_index: AtomicNodeIndex(..),
                                        range: 324..331,
                                        value: Name(
                                            ExprName {
                                                node_index: AtomicNodeIndex(..),
                                                range: 330..331,
                                                id: Name("x"),
                                                ctx: Load,
                                            },
                                        ),
                                    },
                                ),
                            ),
                            body: [
                                Expr(
                                    StmtExpr {
                                        node_index: AtomicNodeIndex(..),
                                        range: 333..336,
                                        value: EllipsisLiteral(
                                            ExprEllipsisLiteral {
                                                node_index: AtomicNodeIndex(..),
                                                range: 333..336,
                                            },
                                        ),
                                    },
                                ),
                            ],
                        },
                    ],
                },
            ),
            If(
                StmtIf {
                    node_index: AtomicNodeIndex(..),
                    range: 337..374,
                    test: Yield(
                        ExprYield {
                            node_index: AtomicNodeIndex(..),
                            range: 341..348,
                            value: Some(
                                Name(
                                    ExprName {
                                        node_index: AtomicNodeIndex(..),
                                        range: 347..348,
                                        id: Name("x"),
                                        ctx: Load,
                                    },
                                ),
                            ),
                        },
                    ),
                    body: [
                        Expr(
                            StmtExpr {
                                node_index: AtomicNodeIndex(..),
                                range: 351..354,
                                value: EllipsisLiteral(
                                    ExprEllipsisLiteral {
                                        node_index: AtomicNodeIndex(..),
                                        range: 351..354,
                                    },
                                ),
                            },
                        ),
                    ],
                    elif_else_clauses: [
                        ElifElseClause {
                            range: 355..374,
                            node_index: AtomicNodeIndex(..),
                            test: Some(
                                Yield(
                                    ExprYield {
                                        node_index: AtomicNodeIndex(..),
                                        range: 361..368,
                                        value: Some(
                                            Name(
                                                ExprName {
                                                    node_index: AtomicNodeIndex(..),
                                                    range: 367..368,
                                                    id: Name("x"),
                                                    ctx: Load,
                                                },
                                            ),
                                        ),
                                    },
                                ),
                            ),
                            body: [
                                Expr(
                                    StmtExpr {
                                        node_index: AtomicNodeIndex(..),
                                        range: 371..374,
                                        value: EllipsisLiteral(
                                            ExprEllipsisLiteral {
                                                node_index: AtomicNodeIndex(..),
                                                range: 371..374,
                                            },
                                        ),
                                    },
                                ),
                            ],
                        },
                    ],
                },
            ),
        ],
    },
)
```
