Skip to content

Commit

Permalink
Fix bug with implicit concatenated string preceded by comment
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Oct 23, 2024
1 parent 4096009 commit f3256b8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,13 @@ def byte_string_in_docstring_position():

def f_string_in_docstring_position():
f" don't trim the" "f-string literal "


##############################################################################
# Regressions
##############################################################################

LEEEEEEEEEEEEEEEEEEEEEEFT = RRRRRRRRIIIIIIIIIIIIGGGGGHHHT | {
"entityNameeeeeeeeeeeeeeeeee", # comment must be long enough to
"some long implicit concatenated string" "that should join"
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ impl FormatNodeRule<ExprStringLiteral> for FormatExprStringLiteral {
}
}

in_parentheses_only_group(&FormatImplicitConcatenatedString::new(item))
in_parentheses_only_group(&FormatImplicitConcatenatedString::new(item)).fmt(f)
}
.fmt(f),
}
}
}
Expand Down
1 change: 0 additions & 1 deletion crates/ruff_python_formatter/src/string/implicit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ impl Format<PyFormatContext<'_>> for FormatImplicitConcatenatedStringExpanded<'_

let part_comments = comments.leading_dangling_trailing(&part);
joiner.entry(&format_args![
line_suffix_boundary(),
leading_comments(part_comments.leading),
format_part,
trailing_comments(part_comments.trailing)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,16 @@ def byte_string_in_docstring_position():
def f_string_in_docstring_position():
f" don't trim the" "f-string literal "
##############################################################################
# Regressions
##############################################################################
LEEEEEEEEEEEEEEEEEEEEEEFT = RRRRRRRRIIIIIIIIIIIIGGGGGHHHT | {
"entityNameeeeeeeeeeeeeeeeee", # comment must be long enough to
"some long implicit concatenated string" "that should join"
}
```
## Outputs
Expand Down Expand Up @@ -651,4 +661,14 @@ def byte_string_in_docstring_position():
def f_string_in_docstring_position():
f" don't trim thef-string literal "
##############################################################################
# Regressions
##############################################################################
LEEEEEEEEEEEEEEEEEEEEEEFT = RRRRRRRRIIIIIIIIIIIIGGGGGHHHT | {
"entityNameeeeeeeeeeeeeeeeee", # comment must be long enough to
"some long implicit concatenated stringthat should join",
}
```

0 comments on commit f3256b8

Please sign in to comment.