Skip to content

D208 should outdent whole blocks and not line-byline #8695

@ThiefMaster

Description

@ThiefMaster
def test(categ_ids, start_dt, end_dt):
    """Retrieve time blocks that fall within a specific time interval.

       :param categ_ids: iterable containing list of category IDs
       :param start_dt: start of search interval (``datetime``, expected
                        to be in display timezone)
       :param end_dt: end of search interval (``datetime`` in expected
                      to be in display timezone)
    """

ruff --isolated --select D208 --fix does this:

def test(categ_ids, start_dt, end_dt):
    """Retrieve time blocks that fall within a specific time interval.

    :param categ_ids: iterable containing list of category IDs
    :param start_dt: start of search interval (``datetime``, expected
    to be in display timezone)
    :param end_dt: end of search interval (``datetime`` in expected
    to be in display timezone)
    """

But this would be sufficient to fix the violation and preserve the intent of the indentation that's not part of the over-indentation:

def test(categ_ids, start_dt, end_dt):
    """Retrieve time blocks that fall within a specific time interval.

    :param categ_ids: iterable containing list of category IDs
    :param start_dt: start of search interval (``datetime``, expected
                     to be in display timezone)
    :param end_dt: end of search interval (``datetime`` in expected
                   to be in display timezone)
    """

IMHO the behavior of the fix should be less aggressive or the fix should be marked as unsafe by default.

D207 should probably be adapted likewise when indenting under-indented docstrings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docstringRelated 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