Ruff rules SIM for simplification#337
Merged
aaronliu0130 merged 1 commit intodevelopfrom Mar 15, 2025
Merged
Conversation
f6df434 to
3cd4953
Compare
aaronliu0130
approved these changes
Mar 14, 2025
Comment on lines
-4764
to
+4763
| if keyword := re.search( | ||
| r"\b(else if|if|while|for|switch)" # These have parens | ||
| r"\s*\(.*\)\s*(?:\[\[(?:un)?likely\]\]\s*)?{\s*[^\s\\};]", | ||
| line, | ||
| ): | ||
| error( | ||
| filename, | ||
| linenum, | ||
| "whitespace/newline", | ||
| 5, | ||
| f"Controlled statements inside brackets of {keyword.group(1)} clause" | ||
| " should be on a separate line", | ||
| if ( | ||
| keyword := re.search( | ||
| r"\b(else if|if|while|for|switch)" # These have parens | ||
| r"\s*\(.*\)\s*(?:\[\[(?:un)?likely\]\]\s*)?{\s*[^\s\\};]", | ||
| line, | ||
| ) | ||
| ) or ( | ||
| keyword := re.search( | ||
| r"\b(else|do|try)" # These don't have parens | ||
| r"\s*(?:\[\[(?:un)?likely\]\]\s*)?{\s*[^\s\\}]", | ||
| line, |
Member
There was a problem hiding this comment.
I wonder why it put everything in brackets...
Member
Author
There was a problem hiding this comment.
Assignment Operator may require parentheses. Also there is a RUF rule that adds parens to clarify precedence between and, or, not.
cclauss
added a commit
that referenced
this pull request
Mar 16, 2025
aaronliu0130
pushed a commit
that referenced
this pull request
Mar 16, 2025
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.
https://docs.astral.sh/ruff/rules/#flake8-simplify-sim