retain parentheses for if exprs

This commit is contained in:
Brent Westbrook 2025-10-20 15:11:21 -04:00
parent 9589542c60
commit c1ba13e3e9
1 changed files with 1 additions and 1 deletions

View File

@ -89,7 +89,7 @@ impl NeedsParentheses for ExprIf {
parent: AnyNodeRef, parent: AnyNodeRef,
_context: &PyFormatContext, _context: &PyFormatContext,
) -> OptionalParentheses { ) -> OptionalParentheses {
if parent.is_expr_await() { if parent.is_expr_await() || parent.is_comprehension() {
OptionalParentheses::Always OptionalParentheses::Always
} else { } else {
OptionalParentheses::Multiline OptionalParentheses::Multiline