Fix formatting of single with-item with trailing comment (#14005)

This commit is contained in:
Micha Reiser 2024-11-01 09:08:06 +01:00 committed by GitHub
parent 20b8a43017
commit cf0f5e1318
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 276 additions and 14 deletions

View file

@ -328,3 +328,42 @@ with aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
if True:
with anyio.CancelScope(shield=True) if get_running_loop() else contextlib.nullcontext() as b:
pass
# Regression test for https://github.com/astral-sh/ruff/issues/14001
with (
open(
"some/path.txt",
"rb",
)
if True
else open("other/path.txt")
# Bar
):
pass
with ( # trailing comment
open(
"some/path.txt",
"rb",
)
if True
else open("other/path.txt")
# Bar
):
pass
with (
(
open(
"some/path.txt",
"rb",
)
if True
else open("other/path.txt")
)
# Bar
):
pass