-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[
flake8-simplify
] Further simplify to binary in preview for `if-els…
…e-block-instead-of-if-exp (SIM108)` (#12796) In most cases we should suggest a ternary operator, but there are three edge cases where a binary operator is more appropriate. Given an if-else block of the form ```python if test: target_var = body_value else: target_var = else_value ``` This PR updates the check for SIM108 to the following: - If `test == body_value` and preview enabled, suggest to replace with `target_var = test or else_value` - If `test == not body_value` and preview enabled, suggest to replace with `target_var = body_value and else_value` - If `not test == body_value` and preview enabled, suggest to replace with `target_var = body_value and else_value` - Otherwise, suggest to replace with `target_var = body_value if test else else_value` Closes #12189.
- Loading branch information
Showing
5 changed files
with
698 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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 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 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.