[refurb] Mark single-item-membership-test fix as always unsafe (FURB171)#20279
Conversation
| Applicability::Safe | ||
| }; | ||
| // All supported cases can change runtime behavior; mark as unsafe. | ||
| let applicability = Applicability::Unsafe; |
There was a problem hiding this comment.
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.
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.
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.
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.