Skip to content

Commit

Permalink
feat: let SIM210 return expressions without bool() wrapping (astral-s…
Browse files Browse the repository at this point in the history
  • Loading branch information
spaceone committed Jan 31, 2023
1 parent 84a8b62 commit ff77eb5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
23 changes: 12 additions & 11 deletions src/rules/flake8_simplify/rules/ast_ifexp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,19 @@ pub fn explicit_true_false_in_ifexpr(
Range::from_located(expr),
);
if checker.patch(diagnostic.kind.rule()) {
let bool_expr = match test.node {
ExprKind::Compare { .. } => test.clone(),
_ => 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_expr(
&create_expr(ExprKind::Call {
func: Box::new(create_expr(ExprKind::Name {
id: "bool".to_string(),
ctx: ExprContext::Load,
})),
args: vec![test.clone()],
keywords: vec![],
}),
checker.stylist,
),
unparse_expr(&bool_expr, checker.stylist),
expr.location,
expr.end_location.unwrap(),
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ expression: diagnostics
column: 29
fix:
content:
- bool(b != c)
- b != c
location:
row: 3
column: 4
Expand Down

0 comments on commit ff77eb5

Please sign in to comment.