-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Labels
formatterRelated to the formatterRelated to the formatterhelp wantedContributions especially welcomeContributions especially welcomestyleHow should formatted code lookHow should formatted code look
Description
From Black's changelog. Last checked 16.09.2024, Last release: v24.8.0.
Goals:
- Close parity with Black when migrating from Black to Ruff
- Fix Ruff specific bugs
- Innovate on local formatting (to keep close parity with black)
Preview Styles
Black preview styles
-
remove_redundant_guard_parensParenthesizematch..caseifguards #13513 -
parens_for_long_if_clauses_in_case_block(related toremove_redundant_guard_parens): See #10969 Parenthesizematch..caseifguards #13513 -
no_normalize_fmt_skip_whitespace: Don't normalize leading whitespace beforefmt: skipcomments.
Black unstable styles
- [
hug_parens_with_braces_and_square_brackets] -
: We decided not to support this style for now because it introduces new parentheses.wrap_long_dict_values_in_parens -
non goal. Maybe a simplified version of it that only joins implicitly concatenated stringsmultiline_string_handling
Ruff preview styles
Ruff specific preview styles that we may want to stabilize
-
f_string_formatting(style improvement)- Improve backport friendliness of quotes in Python 3.12 f-string placeholders #11056
- formatter should change f strings using single quotes with nested double quotes to use double quotes when
target-versionispy312#13237 - F-String formatting in assignment positions #13813
- F-string formatting: Invalid syntax for format-spec with double quotes when targeting pre Python 3.12 #14608
- fixes [
ruff] Formatting hex codes changes output with f-string debug #14766
-
comprehension_leading_expression_comments_same_line(bugfix) -
with_single_item_pre_39_enabled(style improvement) -
f_string_implicit_concatenated_string_literal_quotes(bugfix)
Ruff improvements
- Unnecessary parentheses around return-type annotations Fix parentheses around return type annotations #13381
- Implicit string formatting
- Can omit parentheses layout for patterns: Related to
remove_redundant_guard_parensandparens_for_long_if_clauses_in_case_block
Open Bugs
Existing bugs in the ruff formatter for which no preview style exists.
Require a new style guide
Bug fixes that change how existing code is formatted and require a
- line length calculation for docstring code block is incorrect when using
dynamic - Handling of blank lines between module docstring and a comment (unclear if it requires a new style guide) @konstin
- Parenthesize assignment values that fit into the line length
- Handle over-long lambda expressions (possibly requires a new style guide)
Bug fixes that don't change existing formatting
Bug fixes that don't require a new style guide because they don't change existing cod
- Preserve trailing whitespace in docstring examples
- Incorrect docstring code block formatting for statement sequences
- Trailing parenthesized function return type comment becomes leading comment
- Handling of empty lines after
; - Suppressing statement sequences
- Using
fmt:skipto suppress compound statements
Black Bug fixes
Black preview styles that are related to Black-specific bug fixes. Ruff already handles those cases correctly
pep646_typed_star_arg_type_var_tupleunify_docstring_detection: Format module and single quoted docstringstyped_params_trailing_commais_simple_lookup_for_doublestar_expressiondocstring_check_for_newlinepep646_typed_star_arg_type_var_tuple
Needs fixing
AlexWaygood, stinodego, sbrugman, T-256 and hongbo-miao
Metadata
Metadata
Assignees
Labels
formatterRelated to the formatterRelated to the formatterhelp wantedContributions especially welcomeContributions especially welcomestyleHow should formatted code lookHow should formatted code look