mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-18 17:41:12 +00:00
Allow up to two newlines before trailing clause body comments (#7575)
## Summary This is the peer to https://github.com/astral-sh/ruff/pull/7557, but for "leading" clause comments, like: ```python if True: pass # comment else: pass ``` In this case, we again want to allow up to two newlines at the top level. ## Test Plan `cargo test` No changes. Before: | project | similarity index | total files | changed files | |--------------|------------------:|------------------:|------------------:| | cpython | 0.76083 | 1789 | 1631 | | django | 0.99983 | 2760 | 36 | | transformers | 0.99963 | 2587 | 323 | | twine | 1.00000 | 33 | 0 | | typeshed | 0.99979 | 3496 | 22 | | warehouse | 0.99967 | 648 | 15 | | zulip | 0.99972 | 1437 | 21 | After: | project | similarity index | total files | changed files | |--------------|------------------:|------------------:|------------------:| | cpython | 0.76083 | 1789 | 1631 | | django | 0.99983 | 2760 | 36 | | transformers | 0.99963 | 2587 | 323 | | twine | 1.00000 | 33 | 0 | | typeshed | 0.99979 | 3496 | 22 | | warehouse | 0.99967 | 648 | 15 | | zulip | 0.99972 | 1437 | 21 |
This commit is contained in:
parent
2759db6604
commit
7f1456a2c9
3 changed files with 73 additions and 3 deletions
|
@ -186,6 +186,28 @@ if True:
|
|||
else:
|
||||
pass
|
||||
|
||||
if True:
|
||||
pass
|
||||
# comment
|
||||
else:
|
||||
pass
|
||||
|
||||
if True:
|
||||
pass
|
||||
|
||||
# comment
|
||||
else:
|
||||
pass
|
||||
|
||||
if True:
|
||||
pass
|
||||
|
||||
|
||||
# comment
|
||||
else:
|
||||
pass
|
||||
|
||||
|
||||
# Regression test for https://github.com/astral-sh/ruff/issues/5337
|
||||
if parent_body:
|
||||
if current_body:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue