-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Hi
January isn't too far off anymore ;), and I was wondering if you already have plans for what preview features you want to stabilize as part of the Black 2025 style guide.
I'm working on Ruff's formatter, and my goal is to align Ruff's preview-style promotions with Black's to have a unified 2025 Python style guide (at least style guides that are very close).
New Black preview styles that you implemented during 2024 that I'm aware of (that aren't bug fixes):
remove_redundant_guard_parensParenthesizematch..caseifguards astral-sh/ruff#13513parens_for_long_if_clauses_in_case_block(related toremove_redundant_guard_parens): See #10969 Parenthesizematch..caseifguards astral-sh/ruff#13513no_normalize_fmt_skip_whitespace: Don't normalize leading whitespace beforefmt: skipcomments.
Ruff already supports the two match..case preview styles. We might get around to implementing no_normalize_fmt_skip_whitespace as well, but I don't consider it as crucial as it is a minor style change.
Black preview styles that weren't stabilized last year:
wrap_long_dict_values_in_parens: We decided not to support this style for now because it introduces new parentheses which is a paradigma change.multiline_string_handling. We plan on shipping a simplified version of this, see belowhug_parens_with_braces_and_square_brackets: I would love to see this stabilize but I'm aware it's a big change and there are some open questions.hex_codes_in_unicode_sequences: We stabilized this change last year because we assumed Black did, too. We haven't received much push back but some users assumed that changing the casing changes the runtime values (Ruff formatter - unicode string inside of Enum object always lowercasing characters astral-sh/ruff#13859) and some users wished that Ruff defaults to lowercase (Feature request: Option to use lowercase hex literals astral-sh/ruff#10432)
The following are Ruff style changes that we consider to ship as part of the 2025 style guide:
join_implicit_concatenated_stringsand Join implicit concatenated strings when they fit on a line astral-sh/ruff#13663: This is a simplified version ofmultiline_string_handlingthat only joins, but never automatically splits strings. The overall changes look very promising to me. However, I had to make some changes to theassertformatting that would be a medium large deviation from Blackfstring-formattingand Alternate quotes for strings inside f-strings in preview astral-sh/ruff#13860: Format f-string expressions. This includes normalizing the quotes and formatting the nested expressions (where permitted)
I would appreciate any comments regarding your plans for the Black 2025 style guide as well as any concerns you may have about the new Ruff preview styles.