Skip to content

Commit e4230b6

Browse files
committed
Move to preview style, remove cruft, and add to changelog
Signed-off-by: cobalt <[email protected]>
1 parent e4d8575 commit e4230b6

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

CHANGES.md

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
(#4498)
2525
- Remove parentheses around sole list items (#4312)
2626
- Collapse multiple empty lines after an import into one (#4489)
27+
- Prevent `string_processing` and `wrap_long_dict_values_in_parens` from removing
28+
parenthesis around long dictionary values (#4377)
2729

2830
### Configuration
2931

@@ -43,6 +45,7 @@
4345
### Performance
4446

4547
<!-- Changes that improve Black's performance. -->
48+
4649
- Speed up the `is_fstring_start` function in Black's tokenizer (#4541)
4750

4851
### Output

src/black/linegen.py

+11-12
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,8 @@ def _maybe_split_omitting_optional_parens(
988988
not can_be_split(rhs.body)
989989
and not is_line_short_enough(rhs.body, mode=mode)
990990
and not (
991-
rhs.opening_bracket.parent
991+
Preview.wrap_long_dict_values_in_parens
992+
and rhs.opening_bracket.parent
992993
and rhs.opening_bracket.parent.parent
993994
and rhs.opening_bracket.parent.parent.type == syms.dictsetmaker
994995
)
@@ -1032,7 +1033,8 @@ def _prefer_split_rhs_oop_over_rhs(
10321033

10331034
# Retain optional parens around dictionary values
10341035
if (
1035-
rhs.opening_bracket.parent
1036+
Preview.wrap_long_dict_values_in_parens
1037+
and rhs.opening_bracket.parent
10361038
and rhs.opening_bracket.parent.parent
10371039
and rhs.opening_bracket.parent.parent.type == syms.dictsetmaker
10381040
and rhs.body.bracket_tracker.delimiters
@@ -1639,22 +1641,19 @@ def maybe_make_parens_invisible_in_atom(
16391641
or is_empty_tuple(node)
16401642
or is_one_tuple(node)
16411643
or (is_yield(node) and parent.type != syms.expr_stmt)
1644+
or (
1645+
# This condition tries to prevent removing non-optional brackets
1646+
# around a tuple, however, can be a bit overzealous so we provide
1647+
# and option to skip this check for `for` and `with` statements.
1648+
not remove_brackets_around_comma
1649+
and max_delimiter_priority_in_atom(node) >= COMMA_PRIORITY
1650+
)
16421651
or is_tuple_containing_walrus(node)
16431652
or is_tuple_containing_star(node)
16441653
or is_generator(node)
16451654
):
16461655
return False
16471656

1648-
max_delimiter_priority = max_delimiter_priority_in_atom(node)
1649-
# This condition tries to prevent removing non-optional brackets
1650-
# around a tuple, however, can be a bit overzealous so we provide
1651-
# and option to skip this check for `for` and `with` statements.
1652-
if not remove_brackets_around_comma and max_delimiter_priority >= COMMA_PRIORITY:
1653-
return False
1654-
1655-
# if parent.type == syms.dictsetmaker and max_delimiter_priority != 0:
1656-
# return False
1657-
16581657
if is_walrus_assignment(node):
16591658
if parent.type in [
16601659
syms.annassign,

0 commit comments

Comments
 (0)