mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00
Fix formatter with-statement after-as own line comment instability (#6033)
**Summary** Fix an instability in with statement formatter when there is an own line comment as the `as` ```python with ( a as # bad comment b): ``` **Test Plan** Added the comment to the test cases.
This commit is contained in:
parent
a9f535997d
commit
7f3797185c
4 changed files with 44 additions and 11 deletions
|
@ -31,6 +31,7 @@ with (
|
|||
with (
|
||||
a # a
|
||||
as # as
|
||||
# own line
|
||||
b # b
|
||||
, # comma
|
||||
c # c
|
||||
|
@ -38,6 +39,13 @@ with (
|
|||
... # body
|
||||
# body trailing own
|
||||
|
||||
with (
|
||||
a # a
|
||||
as # as
|
||||
# own line
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb # b
|
||||
): pass
|
||||
|
||||
|
||||
with (a,): # magic trailing comma
|
||||
...
|
||||
|
@ -142,12 +150,21 @@ with (
|
|||
|
||||
|
||||
with (
|
||||
a as b, # a # as # b # comma
|
||||
a as # a # as
|
||||
# own line
|
||||
b, # b # comma
|
||||
c, # c
|
||||
): # colon
|
||||
... # body
|
||||
# body trailing own
|
||||
|
||||
with (
|
||||
a as # a # as
|
||||
# own line
|
||||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb # b
|
||||
):
|
||||
pass
|
||||
|
||||
|
||||
with (
|
||||
a,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue