diff --git a/src/rules/flake8_simplify/rules/ast_if.rs b/src/rules/flake8_simplify/rules/ast_if.rs index 34eb8c79e7..ebabd01007 100644 --- a/src/rules/flake8_simplify/rules/ast_if.rs +++ b/src/rules/flake8_simplify/rules/ast_if.rs @@ -178,7 +178,14 @@ pub fn return_bool_condition_directly(checker: &mut Checker, stmt: &Stmt) { && !has_comments_in(Range::from_located(stmt), checker.locator) { let return_stmt = create_stmt(StmtKind::Return { - value: Some(test.clone()), + value: Some(Box::new(create_expr(ExprKind::Call { + func: Box::new(create_expr(ExprKind::Name { + id: "bool".to_string(), + ctx: ExprContext::Load, + })), + args: vec![(**test).clone()], + keywords: vec![], + }))), }); diagnostic.amend(Fix::replacement( unparse_stmt(&return_stmt, checker.stylist), diff --git a/src/rules/flake8_simplify/rules/ast_ifexp.rs b/src/rules/flake8_simplify/rules/ast_ifexp.rs index 1b642b43cf..f2c01cd212 100644 --- a/src/rules/flake8_simplify/rules/ast_ifexp.rs +++ b/src/rules/flake8_simplify/rules/ast_ifexp.rs @@ -40,7 +40,7 @@ pub fn explicit_true_false_in_ifexpr( id: "bool".to_string(), ctx: ExprContext::Load, })), - args: vec![create_expr(test.node.clone())], + args: vec![test.clone()], keywords: vec![], }), checker.stylist, diff --git a/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM103_SIM103.py.snap b/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM103_SIM103.py.snap index 6a95d1d4e0..3cc9a623ba 100644 --- a/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM103_SIM103.py.snap +++ b/src/rules/flake8_simplify/snapshots/ruff__rules__flake8_simplify__tests__SIM103_SIM103.py.snap @@ -12,7 +12,7 @@ expression: diagnostics column: 20 fix: content: - - return a + - return bool(a) location: row: 3 column: 4 @@ -30,7 +30,7 @@ expression: diagnostics column: 20 fix: content: - - return b + - return bool(b) location: row: 13 column: 4 @@ -48,7 +48,7 @@ expression: diagnostics column: 24 fix: content: - - return b + - return bool(b) location: row: 24 column: 8