Skip to content

Formatter: wrap_long_dict_values_in_parens preview style #8897

@MichaReiser

Description

@MichaReiser

Implement Black's wrap_long_dict_values_in_parens style as a Ruff preview style.

Note:
This new style may not be accepted as part of Black's 2024 style guide.

my_dict = {
    "a key in my dict": a_very_long_variable * and_a_very_long_function_call() * and_another_long_func() / 100000.0
}

Ruff Stable

my_dict = {
    "a key in my dict": a_very_long_variable
    * and_a_very_long_function_call()
    * and_another_long_func()
    / 100000.0
}

Black Preview

my_dict = {
    "a key in my dict": (
        a_very_long_variable
        * and_a_very_long_function_call()
        * and_another_long_func()
        / 100000.0
    )
}

This new style does not apply to subscripts, although it probably should? But this is a non goal for now and tracked separately

Metadata

Metadata

Assignees

No one assigned

    Labels

    formatterRelated to the formatterpreviewRelated to preview mode features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions