{"record":{"id":"81202ac71dd7caee","repo":"astral-sh/ruff","slug":"expected-one-simple-statement","errorCode":null,"errorMessage":"Expected one simple statement","messagePattern":"Expected one simple statement","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/ruff_linter/src/rules/flake8_pytest_style/rules/assertion.rs","lineNumber":769,"sourceCode":"    let mut tree = match_module(&module_text)?;\n\n    // Extract the assert statement.\n    let statements = if outer_indent.is_empty() {\n        &mut tree.body\n    } else {\n        let [Statement::Compound(CompoundStatement::FunctionDef(embedding))] = &mut *tree.body\n        else {\n            bail!(\"Expected statement to be embedded in a function definition\")\n        };\n\n        let indented_block = match_indented_block(&mut embedding.body)?;\n        indented_block.indent = Some(outer_indent);\n\n        &mut indented_block.body\n    };\n\n    let [Statement::Simple(simple_statement_line)] = statements.as_slice() else {\n        bail!(\"Expected one simple statement\")\n    };\n\n    let [SmallStatement::Assert(assert_statement)] = simple_statement_line.body.as_slice() else {\n        bail!(\"Expected simple statement to be an assert\")\n    };\n\n    // Extract the individual conditions.\n    let mut conditions: Vec<Expression> = Vec::with_capacity(2);\n    match &assert_statement.test {\n        Expression::UnaryOperation(op) => {\n            if matches!(op.operator, libcst_native::UnaryOp::Not { .. }) {\n                if let Expression::BooleanOperation(boolean_operation) = &*op.expression {\n                    if matches!(boolean_operation.operator, BooleanOp::Or { .. }) {\n                        conditions.push(negate(&parenthesize(\n                            &boolean_operation.left,\n                            &op.expression,\n                        )));\n                        conditions.push(negate(&parenthesize(","sourceCodeStart":751,"sourceCodeEnd":787,"githubUrl":"https://github.com/astral-sh/ruff/blob/26f38c119cac42e4d320ba08f09224fdec74af2c/crates/ruff_linter/src/rules/flake8_pytest_style/rules/assertion.rs#L751-L787","documentation":"An anyhow bail! in the PT018 composite-condition fixer: after extracting the embedded statement, the block does not contain exactly one simple statement line, so the fixer cannot locate the assert to rewrite and aborts.","triggerScenarios":"Thrown at crates/ruff_linter/src/rules/flake8_pytest_style/rules/assertion.rs:769 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the reconstruction only wraps single-statement bodies","Skip the autofix when more than one simple statement is present"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"26f38c119cac42e4d320ba08f09224fdec74af2c","analyzedAt":"2026-09-05T10:32:37.492Z","contentChangedAt":"2026-09-05T10:32:37.492Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}