mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 11:59:10 +00:00
Don't mistake a following if for an elif (#5296)
In the following code, the comment used to get wrongly associated with
the `if False` since it looked like an elif. This fixes it by checking
the indentation and adding a regression test
```python
if True:
pass
else: # Comment
if False:
pass
pass
```
Originally found in
1570b94a02/gradio/external.py (L478)
This commit is contained in:
parent
c52aa8f065
commit
930f03de98
3 changed files with 73 additions and 25 deletions
|
@ -62,3 +62,12 @@ else:
|
|||
pass
|
||||
# Don't drop this comment 3
|
||||
x = 3
|
||||
|
||||
# Regression test for a following if that could get confused for an elif
|
||||
# Originally found in https://github.com/gradio-app/gradio/blob/1570b94a02d23d051ae137e0063974fd8a48b34e/gradio/external.py#L478
|
||||
if True:
|
||||
pass
|
||||
else: # Comment
|
||||
if False:
|
||||
pass
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue