mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 10:22:24 +00:00
Hug multiline-strings preview style (#9243)
This commit is contained in:
parent
6be73322da
commit
ac02d3aedd
16 changed files with 590 additions and 215 deletions
43
crates/ruff_python_formatter/resources/test/fixtures/ruff/multiline_string_deviations.py
vendored
Normal file
43
crates/ruff_python_formatter/resources/test/fixtures/ruff/multiline_string_deviations.py
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
# This file documents the deviations for formatting multiline strings with black.
|
||||
|
||||
# Black hugs the parentheses for `%` usages -> convert to fstring.
|
||||
# Can get unreadable if the arguments split
|
||||
# This could be solved by using `best_fitting` to try to format the arguments on a single
|
||||
# line. Let's consider adding this later.
|
||||
# ```python
|
||||
# call(
|
||||
# 3,
|
||||
# "dogsay",
|
||||
# textwrap.dedent(
|
||||
# """dove
|
||||
# coo""" % "cowabunga",
|
||||
# more,
|
||||
# and_more,
|
||||
# "aaaaaaa",
|
||||
# "bbbbbbbbb",
|
||||
# "cccccccc",
|
||||
# ),
|
||||
# )
|
||||
# ```
|
||||
call(3, "dogsay", textwrap.dedent("""dove
|
||||
coo""" % "cowabunga"))
|
||||
|
||||
# Black applies the hugging recursively. We don't (consistent with the hugging style).
|
||||
path.write_text(textwrap.dedent("""\
|
||||
A triple-quoted string
|
||||
actually leveraging the textwrap.dedent functionality
|
||||
that ends in a trailing newline,
|
||||
representing e.g. file contents.
|
||||
"""))
|
||||
|
||||
|
||||
|
||||
# Black avoids parenthesizing the following lambda. We could potentially support
|
||||
# this by changing `Lambda::needs_parentheses` to return `BestFit` but it causes
|
||||
# issues when the lambda has comments.
|
||||
# Let's keep this as a known deviation for now.
|
||||
generated_readme = lambda project_name: """
|
||||
{}
|
||||
|
||||
<Add content here!>
|
||||
""".strip().format(project_name)
|
Loading…
Add table
Add a link
Reference in a new issue