Skip to content

fix: keep two blank lines after attribute docstring before def/class - #384

Open
k0shir0 wants to merge 1 commit into
PyCQA:masterfrom
k0shir0:fix/383-attribute-docstring-spacing
Open

k0shir0 wants to merge 1 commit into
PyCQA:masterfrom
k0shir0:fix/383-attribute-docstring-spacing

Conversation

@k0shir0

@k0shir0 k0shir0 commented Sep 18, 2026

Copy link
Copy Markdown

Fixes #383.

The loop bound in _get_attribute_docstring_newlines shrank as the docstring index grew, so files with code before the attribute docstring collapsed two blank lines before a top-level def/class to one. This also ping-ponged with ruff format and Black. Scan to the end of the token list instead.

Verification: new parametrized regression in tests/formatter/test_do_format_code.py covers def and class, 0 to 3 blank lines, and early vs late file position, including idempotence. Full suite: 567 passed, 3 skipped. The issue repro with --diff and --check is clean for both snippets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant