Skip to content

Docstring autofixer adds too much whitespace #3827

@stinodego

Description

@stinodego

My function docstring looks like this, and is missing whitespace between the sections "Parameters" and "Examples"

def pow(self, exponent: int | float | Series | Expr) -> Self:
    """
    Raise expression to the power of the given exponent.

    Parameters
    ----------
    exponent
        ...
    Examples
    --------
    >>> df = pl.DataFrame({"foo": [1, 2, 3, 4]})

    """
    ...

After autofixing, two blank lines are inserted. Only a single blank line would be sufficient:

def pow(self, exponent: int | float | Series | Expr) -> Self:
    """
    Raise expression to the power of the given exponent.

    Parameters
    ----------
    exponent
        ...


    Examples
    --------
    >>> df = pl.DataFrame({"foo": [1, 2, 3, 4]})

    """
    ...

The reason seems to be that D410 (missing blank line after section) and D411 (missing blank line before section) are applied at the same time.

This is on the latest ruff version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocstringRelated to docstring linting or formatting

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions