mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 11:59:10 +00:00
Format StmtFor (#5163)
<!-- Thank you for contributing to Ruff! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary format StmtFor still trying to learn how to help out with the formatter. trying something slightly more advanced than [break](#5158) mostly copied form StmtWhile ## Test Plan snapshots
This commit is contained in:
parent
e71f044f0d
commit
1eccbbb60e
14 changed files with 392 additions and 134 deletions
34
crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/for.py
vendored
Normal file
34
crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/for.py
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
for x in y: # trailing test comment
|
||||
pass # trailing last statement comment
|
||||
|
||||
# trailing for body comment
|
||||
|
||||
# leading else comment
|
||||
|
||||
else: # trailing else comment
|
||||
pass
|
||||
|
||||
# trailing else body comment
|
||||
|
||||
|
||||
for aVeryLongNameThatSpillsOverToTheNextLineBecauseItIsExtremelyLongAndGoesOnAndOnAndOnAndOnAndOnAndOnAndOnAndOnAndOn in anotherVeryLongNameThatSpillsOverToTheNextLineBecauseItIsExtremelyLongAndGoesOnAndOnAndOnAndOnAndOnAndOnAndOnAndOnAndOn: # trailing comment
|
||||
pass
|
||||
|
||||
else:
|
||||
...
|
||||
|
||||
for (
|
||||
x,
|
||||
y,
|
||||
) in z: # comment
|
||||
...
|
||||
|
||||
|
||||
# remove brackets around x,y but keep them around z,w
|
||||
for (x, y) in (z, w):
|
||||
...
|
||||
|
||||
|
||||
# type comment
|
||||
for x in (): # type: int
|
||||
...
|
Loading…
Add table
Add a link
Reference in a new issue