File tree 3 files changed +25
-1
lines changed
crates/ruff_python_formatter
resources/test/fixtures/ruff/statement
3 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -67,3 +67,12 @@ def main() -> None:
67
67
db_request .POST ["name" ]
68
68
)
69
69
)[0 ]
70
+
71
+
72
+ c = b [dddddd , aaaaaa ] = (
73
+ a [
74
+ aaaaaaa ,
75
+ bbbbbbbbbbbbbbbbbbb
76
+ ]
77
+ # comment
78
+ ) = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ impl Format<PyFormatContext<'_>> for FormatTargets<'_> {
69
69
if let Some ( ( first, rest) ) = self . targets . split_first ( ) {
70
70
let comments = f. context ( ) . comments ( ) ;
71
71
72
- let parenthesize = if comments. has_leading ( first) {
72
+ let parenthesize = if comments. has_leading ( first) || comments . has_trailing ( first ) {
73
73
ParenthesizeTarget :: Always
74
74
} else if has_own_parentheses ( first, f. context ( ) ) . is_some ( ) {
75
75
ParenthesizeTarget :: Never
Original file line number Diff line number Diff line change @@ -73,6 +73,15 @@ def main() -> None:
73
73
db_request.POST["name"]
74
74
)
75
75
)[0]
76
+
77
+
78
+ c = b[dddddd, aaaaaa] = (
79
+ a[
80
+ aaaaaaa,
81
+ bbbbbbbbbbbbbbbbbbb
82
+ ]
83
+ # comment
84
+ ) = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
76
85
` ` `
77
86
78
87
## Output
@@ -151,6 +160,12 @@ def main() -> None:
151
160
db_request.POST["name"]
152
161
)
153
162
)[0]
163
+
164
+
165
+ c = b[dddddd, aaaaaa] = (
166
+ a[aaaaaaa, bbbbbbbbbbbbbbbbbbb]
167
+ # comment
168
+ ) = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
154
169
` ` `
155
170
156
171
You can’t perform that action at this time.
0 commit comments