Skip to content

Conflict between check and format with D203 #12220

@arylix

Description

@arylix
class Test:
    """
    Test class docstring.
    """
lint.select = ["D"]
lint.ignore = ["D100", "D200", "D212", "D211"]

When I run ruff check test.py --config ruff.toml I get:

test.py:2:5: D203 [*] 1 blank line required before class docstring
  |
1 |   class Test:
2 |       """
  |  _____^
3 | |     Test class docstring.
4 | |     """
  | |_______^ D203
  |
  = help: Insert 1 blank line before class docstring

Found 1 error.

With --fix Ruff changes the file to:

class Test:

    """
    Test class docstring.
    """

When I now run ruff format test.py --config ruff.toml it redoes the changes and removes the blank line:

class Test:
    """
    Test class docstring.
    """

Ruff version: 0.5.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    incompatibilityIncompatibility between different Ruff tools or rules (formatter, isort, linter)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions