Skip to content

ruff check fix E305 "blank-lines-after-function-or-class" adds incorrectly placed newlines. #11508

@kaddkaka

Description

@kaddkaka

ruff check fix E305 "blank-lines-after-function-or-class" adds incorrectly placed newlines in ruff version 0.4.4

input code:

class A:
    pass

# ====== Cool constants ========
BANANA = 100
APPLE = 200

cmd: ruff check --fix --select=E305 tmp.py --isolated --preview

output:

class A:
    pass

# ====== Cool constants ========


BANANA = 100
APPLE = 200

Expected output:

class A:
    pass


# ====== Cool constants ========
BANANA = 100
APPLE = 200

Could this rule mistakenly identifying the comment as belonging to the class even if the indentation should tell otherwise?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions