mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 05:25:17 +00:00
format StmtWith (#5350)
This commit is contained in:
parent
49cabca3e7
commit
d00559e42a
13 changed files with 380 additions and 80 deletions
54
crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/with.py
vendored
Normal file
54
crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/with.py
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
with aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:
|
||||
...
|
||||
# trailing
|
||||
|
||||
with a, a: # after colon
|
||||
...
|
||||
# trailing
|
||||
|
||||
with (
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
|
||||
):
|
||||
...
|
||||
# trailing
|
||||
|
||||
|
||||
with (
|
||||
a # a
|
||||
, # comma
|
||||
b # c
|
||||
): # colon
|
||||
...
|
||||
|
||||
|
||||
with (
|
||||
a # a
|
||||
as # as
|
||||
b # b
|
||||
, # comma
|
||||
c # c
|
||||
): # colon
|
||||
... # body
|
||||
# body trailing own
|
||||
|
||||
|
||||
with (a,): # magic trailing comma
|
||||
...
|
||||
|
||||
|
||||
with (a): # should remove brackets
|
||||
...
|
||||
|
||||
# TODO: black doesn't wrap this, but maybe we want to anyway?
|
||||
# if we do want to wrap, do we prefer to wrap the entire WithItem or to let the
|
||||
# WithItem allow the `aa + bb` content expression to be wrapped
|
||||
with aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb as c:
|
||||
...
|
||||
|
||||
|
||||
# currently unparsable by black: https://github.com/psf/black/issues/3678
|
||||
with (name_2 for name_0 in name_4):
|
||||
pass
|
||||
with (a, *b):
|
||||
pass
|
Loading…
Add table
Add a link
Reference in a new issue