-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- Thank you for contributing to Ruff! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary <!-- What's the purpose of the change? What does it do, and why? --> The `SIM102` auto-fix fails if `elif` is indented like this: ## Example ```python def f(): # SIM102 if a: pass elif b: if c: d ``` ``` > cargo run -p ruff_cli -- check --select SIM102 --fix a.py ... error: Failed to fix nested if: Failed to extract statement from source a.py:5:5: SIM102 Use a single `if` statement instead of nested `if` statements Found 1 error. ``` ## Test Plan <!-- How was it tested? --> New test
- Loading branch information
Showing
4 changed files
with
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -156,3 +156,12 @@ | |
if True: | ||
if a: | ||
pass | ||
|
||
|
||
# SIM102 | ||
def f(): | ||
if a: | ||
pass | ||
elif b: | ||
if c: | ||
d |
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