Fix handling of trailing target comment (#9051)

This commit is contained in:
Micha Reiser 2023-12-08 14:00:36 +09:00 committed by GitHub
parent a224f19903
commit d0d88d9375
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 1 deletions

View file

@ -69,7 +69,7 @@ impl Format<PyFormatContext<'_>> for FormatTargets<'_> {
if let Some((first, rest)) = self.targets.split_first() {
let comments = f.context().comments();
let parenthesize = if comments.has_leading(first) {
let parenthesize = if comments.has_leading(first) || comments.has_trailing(first) {
ParenthesizeTarget::Always
} else if has_own_parentheses(first, f.context()).is_some() {
ParenthesizeTarget::Never