Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ThiefMaster opened this issue Nov 15, 2023 · 2 comments · Fixed by #8699
Closed

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

ThiefMaster opened this issue Nov 15, 2023 · 2 comments · Fixed by #8699
Labels
docstring Related to docstring linting or formatting

Comments

@ThiefMaster
Copy link
Contributor

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.

@zanieb
Copy link
Member

zanieb commented Nov 15, 2023

Thanks for the report, let me know if #8699 resolves your problems.

@ThiefMaster
Copy link
Contributor Author

Yes, works exactly as I was hoping for - thanks for the quick fix!

zanieb added a commit that referenced this issue Nov 17, 2023
…d lines (#8699)

Closes #8695

We track the smallest offset seen for overindented lines then only
reduce the indentation of the lines that far to preserve indentation in
other lines. This rule's behavior now matches our formatter, which is
nice.

We may want to gate this with preview.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docstring Related to docstring linting or formatting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants