-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[refurb] Mark single-item-membership-test fix as always unsafe (FURB171)
#20279
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
Conversation
| Applicability::Safe | ||
| }; | ||
| // All supported cases can change runtime behavior; mark as unsafe. | ||
| let applicability = Applicability::Unsafe; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, fixes were marked unsafe only for string literals and when comments intersected the edit range, but single‑item list/tuple/set/frozenset cases can also
change behavior (e.g., NaN identity differences and non‑boolean eq), so we now mark all FURB171 fixes as unsafe.
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| FURB171 | 64 | 0 | 0 | 0 | 64 |
ntBre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks good! I just had a couple of minor suggestions. I agree with marking the fix as always unsafe instead of trying to look for the few special safe cases mentioned in the issue. I think that could get pretty complicated.
crates/ruff_linter/src/rules/refurb/rules/single_item_membership_test.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/refurb/rules/single_item_membership_test.rs
Outdated
Show resolved
Hide resolved
refurb] Mark single-item-membership-test fixes as always unsaferefurb] Mark single-item-membership-test fix as always unsafe (FURB171)
ntBre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Just a couple of small docs nits that I'll apply and then merge this :)
Summary
Fixes #20255
Mark single-item-membership-test fixes as always unsafe
Applicability::Unsafefor FURB171 fixesTest Plan
I have added new test cases to
crates/ruff_linter/resources/test/fixtures/refurb/FURB171_0.pyandcrates/ruff_linter/resources/test/fixtures/refurb/FURB171_1.py.