The following docstring
class FooBar:
"""Abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc.
Abcabc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc.
"""
pass
strangely gets formatted to
class FooBar:
"""Abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc
abc.
Abcabc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc.
"""
pass
The problem appears to come from
|
# Google docstrings can preserve string prefixes such as ``rf`` when rebuilt, |
|
# so first-line wrapping reserves two prefix characters plus opening quotes. |
|
GOOGLE_OPENING_QUOTES_WIDTH: Final[int] = 5 |
|
GOOGLE_COMPACT_OPENING_QUOTES_WIDTH: Final[int] = 5 |
which contradicts
|
if isinstance(val, ast.Constant) and isinstance(val.value, str): |
because f prefixed strings are of type ast.JoinedStr and not ast.Constant, and thus never satisfy the condition to count as docstrings.
b and u prefixed strings, while of ast.Constant type, do not seem to get formatted either, albeit for a different reason.
Easy solution, just sweep prefixed docstrings under the rug, and change the constants to:
# First-line wrapping reserves 3 opening quotes.
GOOGLE_OPENING_QUOTES_WIDTH: Final[int] = 3
GOOGLE_COMPACT_OPENING_QUOTES_WIDTH: Final[int] = 3
The following docstring
strangely gets formatted to
The problem appears to come from
format-docstring/format_docstring/line_wrap_google.py
Lines 32 to 35 in ac5aab2
which contradicts
format-docstring/format_docstring/docstring_rewriter.py
Line 580 in ac5aab2
because
fprefixed strings are of typeast.JoinedStrand notast.Constant, and thus never satisfy the condition to count as docstrings.banduprefixed strings, while ofast.Constanttype, do not seem to get formatted either, albeit for a different reason.Easy solution, just sweep prefixed docstrings under the rug, and change the constants to: