Skip to content

Commit

Permalink
Update fix for literal-membership (PLR6201) to be unsafe (#8097)
Browse files Browse the repository at this point in the history
Closes #8096
  • Loading branch information
zanieb authored Oct 20, 2023
1 parent ae41d6f commit 348b649
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ 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::safe_edit(Edit::range_replacement(set, right.range())));
diagnostic.set_fix(Fix::unsafe_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`

Fix
Suggested 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`

Fix
Suggested 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`

Fix
Suggested fix
1 1 | # Errors
2 2 | 1 in [1, 2, 3]
3 3 | 1 in (1, 2, 3)
Expand Down

0 comments on commit 348b649

Please sign in to comment.