-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[RUF021]: Add an autofix #9449
[RUF021]: Add an autofix #9449
Conversation
3bc5e7c
to
795d053
Compare
crates/ruff_linter/src/rules/ruff/rules/parenthesize_logical_operators.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/ruff/rules/parenthesize_logical_operators.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/ruff/rules/parenthesize_logical_operators.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/ruff/rules/parenthesize_logical_operators.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/ruff/rules/parenthesize_logical_operators.rs
Outdated
Show resolved
Hide resolved
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
RUF021 | 144 | 0 | 30 | 114 | 0 |
This is weird -- I can't repro this locally. If I run |
crates/ruff_linter/src/rules/ruff/rules/parenthesize_logical_operators.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/ruff/rules/parenthesize_logical_operators.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/ruff/rules/parenthesize_logical_operators.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/ruff/rules/parenthesize_logical_operators.rs
Outdated
Show resolved
Hide resolved
Okay, I think I addressed everybody's comments! |
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.
Nice!
Thanks all for the reviews! |
Summary
This adds an autofix for the newly added RUF021 (see #9440).
The PR currently only adds an autofix to the diagnostic if:
If we know that both of the above are true, the fix is pretty simple to implement. I think it should also be pretty safe, as well -- we shouldn't be making any changes here that impact the AST.
Two remarks:
Test Plan
cargo test
/cargo insta review