[flake8-simplify] Mark SIM910/SIM911 fix as unsafe when deleting comments#22600
[flake8-simplify] Mark SIM910/SIM911 fix as unsafe when deleting comments#22600eureka928 wants to merge 2 commits intoastral-sh:mainfrom
flake8-simplify] Mark SIM910/SIM911 fix as unsafe when deleting comments#22600Conversation
|
@BurntSushi @MichaReiser would you approve testing and review this PR? |
|
Thanks for your PR
Please give us some time before pinging maintainers. We already get a lot of notifications and more notifications doesn't help us to get things done faster. BurntSushi also doesn't work at this part of the code base at all. |
|
|
All testing passed! |
ntBre
left a comment
There was a problem hiding this comment.
Thank you! This looks great, we just need to update the rule docs to reflect the new unsafety.
crates/ruff_linter/src/rules/flake8_simplify/rules/zip_dict_keys_and_values.rs
Show resolved
Hide resolved
0974249 to
2f6ca10
Compare
|
Ready for review |
flake8-simplify] Mark SIM910/SIM911 fix as unsafe when deleting comments
2f6ca10 to
912b0d2
Compare
amyreese
left a comment
There was a problem hiding this comment.
Please remove the pr_summary markdown files.
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Updated! it was mistake |
Summary
Fixes #18775
The SIM910 (
dict-get-with-none-default) and SIM911 (zip-dict-keys-and-values) rules were silently deleting comments when applying fixes.For example, SIM910 would transform:
This fix marks such transformations as unsafe when comments would be deleted, requiring users to explicitly opt-in with
--unsafe-fixes.Approach
Uses the established
CommentRanges::intersects()pattern already used by other rules in the codebase (as suggested by @MichaReiser in the issue). When comments exist within the expression's range, the fix is marked asApplicability::Unsafeinstead ofApplicability::Safe.Test Plan
Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=42954461