Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fix for literal-membership (PLR6201) to be unsafe #8097

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update fix for literal-membership (PLR6201) to be unsafe
  • Loading branch information
zanieb committed Oct 20, 2023
commit 335ec4225ad7ffbd74da1c310f7b27efb31a5971
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