Fix codeblock dynamic line length calculation for indented examples (#13523)

This commit is contained in:
Micha Reiser 2024-09-27 09:09:07 +02:00 committed by GitHub
parent 7706f561a9
commit c046101b79
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 1276 additions and 20 deletions

View file

@ -44,3 +44,12 @@ pub(crate) fn is_empty_parameters_no_unnecessary_parentheses_around_return_value
pub(crate) fn is_match_case_parentheses_enabled(context: &PyFormatContext) -> bool {
context.is_preview()
}
/// This preview style fixes a bug with the docstring's `line-length` calculation when using the `dynamic` mode.
/// The new style now respects the indent **inside** the docstring and reduces the `line-length` accordingly
/// so that the docstring's code block fits into the global line-length setting.
pub(crate) fn is_docstring_code_block_in_docstring_indent_enabled(
context: &PyFormatContext,
) -> bool {
context.is_preview()
}