Skip to content

Latest version of ruff (0.4.2) removes blank double blank line that was allowed previously #11254

@taranlu-houzz

Description

@taranlu-houzz

ruff --version: 0.4.2

I recently updated to the latest version of ruff and noticed that in specific cases, a double blank line is now getting changed to a single blank line. I strongly prefer to use double blank lines to visually separate some sections of code, and this only seems to happen in one specific scenario so it is kind of driving me crazy. Here is a code snippet that triggers the change:

#!/usr/bin/env python
# -*- coding: utf-8 -*-


"""Run CLI if package is run directly as a module."""


####################################################################################################
# Imports
####################################################################################################


# ==Package==
from ._private import cli_test_utils


####################################################################################################
# Main
####################################################################################################


cli_test_utils.run_app()

When this is formatted using ruff format <file> (no other flags needed), it remove the blank line above # ==Package==, but leaves all other double blank lines:

#!/usr/bin/env python
# -*- coding: utf-8 -*-


"""Run CLI if package is run directly as a module."""


####################################################################################################
# Imports
####################################################################################################

# ==Package==
from ._private import cli_test_utils


####################################################################################################
# Main
####################################################################################################


cli_test_utils.run_app()

In the past, it did not do this. I'm not sure what the previous working version is, but I may try a few previous versions to see if I can narrow it down.

Update: The last version where it didn't delete the blank line was v0.2.2. The next version, v0.3.0 exhibits the new behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingformatterRelated to the formatter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions