@@ -988,7 +988,8 @@ def _maybe_split_omitting_optional_parens(
988
988
not can_be_split (rhs .body )
989
989
and not is_line_short_enough (rhs .body , mode = mode )
990
990
and not (
991
- rhs .opening_bracket .parent
991
+ Preview .wrap_long_dict_values_in_parens
992
+ and rhs .opening_bracket .parent
992
993
and rhs .opening_bracket .parent .parent
993
994
and rhs .opening_bracket .parent .parent .type == syms .dictsetmaker
994
995
)
@@ -1032,7 +1033,8 @@ def _prefer_split_rhs_oop_over_rhs(
1032
1033
1033
1034
# Retain optional parens around dictionary values
1034
1035
if (
1035
- rhs .opening_bracket .parent
1036
+ Preview .wrap_long_dict_values_in_parens
1037
+ and rhs .opening_bracket .parent
1036
1038
and rhs .opening_bracket .parent .parent
1037
1039
and rhs .opening_bracket .parent .parent .type == syms .dictsetmaker
1038
1040
and rhs .body .bracket_tracker .delimiters
@@ -1639,22 +1641,19 @@ def maybe_make_parens_invisible_in_atom(
1639
1641
or is_empty_tuple (node )
1640
1642
or is_one_tuple (node )
1641
1643
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
+ )
1642
1651
or is_tuple_containing_walrus (node )
1643
1652
or is_tuple_containing_star (node )
1644
1653
or is_generator (node )
1645
1654
):
1646
1655
return False
1647
1656
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
-
1658
1657
if is_walrus_assignment (node ):
1659
1658
if parent .type in [
1660
1659
syms .annassign ,
0 commit comments