mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-26 11:59:10 +00:00
Format ExprYield
/ExprYieldFrom
(#5921)
Co-authored-by: Micha Reiser <micha@reiser.io>
This commit is contained in:
parent
c3b506fca6
commit
519dbdffaa
13 changed files with 373 additions and 185 deletions
59
crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/yield.py
vendored
Normal file
59
crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/yield.py
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
l = [1,2,3,4]
|
||||
|
||||
def foo():
|
||||
yield l
|
||||
|
||||
b = yield l
|
||||
|
||||
c = [
|
||||
(yield l) , (
|
||||
yield l
|
||||
|
||||
)]
|
||||
|
||||
with (
|
||||
# Some comment
|
||||
yield
|
||||
):
|
||||
pass
|
||||
|
||||
if (yield):
|
||||
# comment
|
||||
pass
|
||||
|
||||
|
||||
(yield a, b) = (1, 2)
|
||||
|
||||
# some comment
|
||||
for e in l : yield e # some comment
|
||||
|
||||
for e in l:
|
||||
|
||||
|
||||
# some comment
|
||||
|
||||
yield e
|
||||
|
||||
# trail comment
|
||||
|
||||
for e in l:
|
||||
# comment
|
||||
yield (((((((e))))))) # Too many parentheses
|
||||
# comment
|
||||
|
||||
|
||||
for ridiculouslylongelementnameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee in l:
|
||||
yield ridiculouslylongelementnameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
|
||||
|
||||
|
||||
for x in l: #comment
|
||||
yield x + (2 * 4) # trailing comment
|
||||
|
||||
while (
|
||||
|
||||
yield l
|
||||
):
|
||||
pass
|
||||
|
||||
yield from (yield l)
|
||||
|
35
crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/yield_from.py
vendored
Normal file
35
crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/yield_from.py
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
l = [1,2,3,4]
|
||||
|
||||
|
||||
def foo():
|
||||
yield from l # some comment
|
||||
|
||||
# weird indents
|
||||
yield\
|
||||
from\
|
||||
l
|
||||
# indented trailing comment
|
||||
|
||||
a = yield from l
|
||||
|
||||
with (
|
||||
# Comment
|
||||
yield from l
|
||||
# Comment
|
||||
):
|
||||
pass
|
||||
|
||||
c = [(yield from l) , (
|
||||
yield from l
|
||||
|
||||
)]
|
||||
|
||||
while (
|
||||
yield from l
|
||||
):
|
||||
pass
|
||||
|
||||
yield (
|
||||
yield from l
|
||||
)
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue