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:
konstin 2023-06-23 10:07:28 +02:00 committed by GitHub
parent c52aa8f065
commit 930f03de98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 73 additions and 25 deletions

View file

@ -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