-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[pycodestyle
] Auto-fix redundant boolean comparison (E712
)
#17090
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8a6c711
feat: add redundant boolean comparison
knavdeep152002 7c7a250
refactor: redundant boolean comparison and its respective check
knavdeep152002 649eff8
Update snapshots for E712 rule changes"
knavdeep152002 5c30c97
feat: check redundant_boolean_comparison for left expression and move…
knavdeep152002 03d6275
fix: typo on comment
knavdeep152002 1118724
fix: wrap in parenthesis for right side boolean comparator case
knavdeep152002 63258a6
chore: run cargo fmt
knavdeep152002 f45c98b
Update crates/ruff_linter/src/rules/pycodestyle/rules/literal_compari…
knavdeep152002 2cd6971
refactor: redundant comparison
knavdeep152002 246c858
refactor: move helper fn to main file instead of pub fn
knavdeep152002 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Oh, is the parenthesis detection wrong here? I don't think we need these parens.
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.
According to the logic, the comparison of the start indexes is on the
(true) == TrueElement
, and the comparator istrue
. So, there is a mismatch, so a bracket was included.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.
I guess the point I was trying to make is that I would rather not have these parentheses because the expression is valid without them. I would have expected this output here:
The current logic may not be correct if it preserves unnecessary parentheses.
I tried a couple of approaches to get rid of the
range
comparisons in an earlier review and couldn't come up with something better, though, so this doesn't necessarily need to block this PR. It's still an improvement over the old fix.