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

Insert empty line between suite and alternative branch after def/class #12294

Merged
merged 5 commits into from
Jul 15, 2024

Commits on Jul 12, 2024

  1. Insert empty line between suite and alternative branch after def/class

    When there is a function or class definition at the end of a suite followed by the beginning of an alternative block, we have to insert a single empty line between them.
    
    In the if-else-statement example below, we insert an empty line after the `foo` in the if-block, but none after the else-block `foo`, since in the latter case the enclosing suite already adds empty lines.
    
    ```python
    if sys.version_info >= (3, 10):
        def foo():
            return "new"
    else:
        def foo():
            return "old"
    class Bar:
        pass
    ```
    
    To do so, we track whether the current suite is the last one in the current statement with a new option on the suite kind.
    
    Fixes #12199
    konstin committed Jul 12, 2024
    Configuration menu
    Copy the full SHA
    b3d6adb View commit details
    Browse the repository at this point in the history
  2. Gate behind preview

    konstin committed Jul 12, 2024
    Configuration menu
    Copy the full SHA
    5f4f4d8 View commit details
    Browse the repository at this point in the history

Commits on Jul 15, 2024

  1. Update crates/ruff_python_formatter/src/statement/stmt_match.rs

    Co-authored-by: Micha Reiser <micha@reiser.io>
    konstin and MichaReiser authored Jul 15, 2024
    Configuration menu
    Copy the full SHA
    da3e00e View commit details
    Browse the repository at this point in the history
  2. Review

    konstin committed Jul 15, 2024
    Configuration menu
    Copy the full SHA
    4f88f5b View commit details
    Browse the repository at this point in the history
  3. Revert bogus inline

    konstin committed Jul 15, 2024
    Configuration menu
    Copy the full SHA
    2dd7988 View commit details
    Browse the repository at this point in the history