save f.context.comments() to comments

This commit is contained in:
Brent Westbrook 2025-12-11 15:06:44 -05:00
parent 0f1ea90c5c
commit 5fee7534f7
No known key found for this signature in database
1 changed files with 3 additions and 5 deletions

View File

@ -405,11 +405,9 @@ impl Format<PyFormatContext<'_>> for FormatBody<'_> {
// ) // )
// ) // )
// ``` // ```
if is_expression_parenthesized( let comments = f.context().comments();
(*body).into(), if is_expression_parenthesized((*body).into(), comments.ranges(), f.context().source())
f.context().comments().ranges(), && comments.has_leading(*body)
f.context().source(),
) && f.context().comments().has_leading(*body)
{ {
if leading_body_comments.is_empty() { if leading_body_comments.is_empty() {
write!( write!(