Skip to content

Unexpected changes occur when fixing D208 and D209 on the same line #13260

@kubotty

Description

@kubotty

When ruff fixes both D208 (over-indentation) and D209 (new-line-after-last-paragraph) on the same line, it results in unexpected changes.
I share the minimum test case.

Target code:

def test_func(a: int) -> None:
    """Minimum test case.

    Parameters
    ----------
    a : int
        A parameter."""
    pass

Settings in pyproject.toml:

[tool.ruff]
show-fixes = true

[tool.ruff.lint]
select = ["D"]

[tool.ruff.lint.pydocstyle]
convention = "numpy"

Run above command:

ruff check target.py --fix

Expected results:

def test_func(a: int) -> None:
    """Minimum test case.

    Parameters
    ----------
    a : int
        A parameter.
    """
    pass

but, actual:

def test_func(a: int) -> None:
    """Minimum test case.

    Parameters
    ----------
    a : int
    A parameter.
    """
    pass

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdocstringRelated to docstring linting or formattinghelp wantedContributions especially welcomeruleImplementing or modifying a lint rule

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions