Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't mistake a following if for an elif #5296

Merged
merged 2 commits into from
Jun 23, 2023

Commits on Jun 22, 2023

  1. Fix formatter panic with comment after parenthesized dict value

    ## Summary
    
    This snippet used to panic because it expected to see a comma or something similar after the `2` but met the closing parentheses that is not part of the range and panicked
    ```python
    a = {
        1: (2),
        # comment
        3: True,
    }
    ```
    
    Originally found in https://github.com/bolucat/Firefox/blob/636a717ef025c16434997dc89e42351ef740ee6b/testing/marionette/client/marionette_driver/geckoinstance.py#L109
    
    This snippet is also the test plan.
    konstin committed Jun 22, 2023
    Configuration menu
    Copy the full SHA
    b963c7f View commit details
    Browse the repository at this point in the history
  2. Don't mistake a following if for an elif

    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 https://github.com/gradio-app/gradio/blob/1570b94a02d23d051ae137e0063974fd8a48b34e/gradio/external.py#L478
    konstin committed Jun 22, 2023
    Configuration menu
    Copy the full SHA
    97b027a View commit details
    Browse the repository at this point in the history