Manually format comments around := in named expressions (#6634)

## Summary

Attaches comments around the `:=` operator in a named expression as
dangling, and formats them manually in the `named_expr.rs` formatter.

Closes https://github.com/astral-sh/ruff/issues/5695.

## Test Plan

`cargo test`
This commit is contained in:
Charlie Marsh 2023-08-17 23:10:45 -04:00 committed by GitHub
parent a128fe5148
commit 26bba11be6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 194 additions and 9 deletions

View file

@ -8,6 +8,45 @@ if (
):
pass
if (
# 1
x # 2
:= # 3
(y) # 4
):
pass
if (
# 1
x # 2
:= # 3
(y) # 4
# 5
):
pass
if (
# 1
x # 2
# 2.5
:= # 3
# 3.5
y # 4
):
pass
if (
# 1
x # 2
# 2.5
:= # 3
# 3.5
( # 4
y # 5
) # 6
):
pass
y0 = (y1 := f(x))
f(x:=y, z=True)