Skip to content

Commit

Permalink
Convert literal-membership to a safe edit
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Jan 29, 2024
1 parent 0045032 commit 1c8db54
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ pub(crate) fn literal_membership(checker: &mut Checker, compare: &ast::ExprCompa

let literal = checker.locator().slice(right);
let set = format!("{{{}}}", &literal[1..literal.len() - 1]);
diagnostic.set_fix(Fix::unsafe_edit(Edit::range_replacement(
set,
right.range(),
)));
diagnostic.set_fix(Fix::safe_edit(Edit::range_replacement(set, right.range())));

checker.diagnostics.push(diagnostic);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ literal_membership.py:2:6: PLR6201 [*] Use a `set` literal when testing for memb
|
= help: Convert to `set`

Unsafe fix
Safe fix
1 1 | # Errors
2 |-1 in [1, 2, 3]
2 |+1 in {1, 2, 3}
Expand All @@ -30,7 +30,7 @@ literal_membership.py:3:6: PLR6201 [*] Use a `set` literal when testing for memb
|
= help: Convert to `set`

Unsafe fix
Safe fix
1 1 | # Errors
2 2 | 1 in [1, 2, 3]
3 |-1 in (1, 2, 3)
Expand All @@ -53,7 +53,7 @@ literal_membership.py:4:6: PLR6201 [*] Use a `set` literal when testing for memb
|
= help: Convert to `set`

Unsafe fix
Safe fix
1 1 | # Errors
2 2 | 1 in [1, 2, 3]
3 3 | 1 in (1, 2, 3)
Expand Down

0 comments on commit 1c8db54

Please sign in to comment.