Repository navigation
[pylint] Correct ordering of arguments in fix for if-stmt-min-max (PLR1730) - #16080
Merged
Merged
Conversation
Contributor
|
pylint] Correct ordering of arguments in fix for if-stmt-min-max (PLR1730)
MichaReiser
reviewed
Feb 11, 2025
| else if cmp_left == assignment_value && cmp_right == target { | ||
| match op { | ||
| CmpOp::Lt => (MinMax::Min, true), | ||
| CmpOp::LtE => (MinMax::Min, true), |
Member
There was a problem hiding this comment.
I think this is incorrect and should instead be false to match your table from the PR summary.
Please also carefully review the snapshot changes.
Contributor
Author
There was a problem hiding this comment.
In this case where are in the situation:
if a <= b:
b = awhich is fixed by b = min(a, b).
So you are right ;-)
Please also carefully review the snapshot changes.
I corrected the snapshot and I double-checked all the other changes I did. Everything follow the table posted in the description of the PR.
dhruvmanila
added a commit
that referenced
this pull request
Feb 24, 2025
## Summary This is mainly on me for not noticing this during the last release but I noticed in the last changelog that there's only 1 bug fix which didn't seem correct as I saw multiple of them so I looked at a couple of PRs that are in "Rule changes" section and the PRs that were marked with the `bug` label was categorized there because 1. It _also_ had other labels like `rule` and `fixes` (#16080, #16110, #16219, etc.) 2. Some PRs didn't have the `bug` label (but the issue as marked as `bug`) but _only_ labels like "fixes" (#16011, #16132, etc.)
KotlinIsland
pushed a commit
to KotlinIsland/basedpython
that referenced
this pull request
May 1, 2026
## Summary This is mainly on me for not noticing this during the last release but I noticed in the last changelog that there's only 1 bug fix which didn't seem correct as I saw multiple of them so I looked at a couple of PRs that are in "Rule changes" section and the PRs that were marked with the `bug` label was categorized there because 1. It _also_ had other labels like `rule` and `fixes` (astral-sh/ruff#16080, astral-sh/ruff#16110, astral-sh/ruff#16219, etc.) 2. Some PRs didn't have the `bug` label (but the issue as marked as `bug`) but _only_ labels like "fixes" (astral-sh/ruff#16011, astral-sh/ruff#16132, etc.)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The PR addresses the issue #16040 .
The logic used into the rule is the following:
Suppose to have an expression of the form
where
a,b,canddare Python obj andcmpone of<,>,<=,>=.Then:
if a=c and b=d<=fix witha = max(b, a)>=fix witha = min(b, a)>fix witha = min(a, b)<fix witha = max(a, b)if a=d and b=c<=fix withb = min(a, b)>=fix withb = max(a, b)>fix withb = max(b, a)<fix withb = min(b, a)do nothing, i.e., we cannot fix this case.
In total we have 8 different and possible cases.
I added them in the tests.
Please double-check that I didn't make any mistakes. It's quite easy to mix up > and <.