Skip to content

Commit

Permalink
maybe finish it!
Browse files Browse the repository at this point in the history
Signed-off-by: cobalt <[email protected]>
  • Loading branch information
cobaltt7 committed Dec 23, 2024
1 parent 22a18b8 commit d39e79d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions src/black/linegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1627,17 +1627,20 @@ def maybe_make_parens_invisible_in_atom(
or is_empty_tuple(node)
or is_one_tuple(node)
or (is_yield(node) and parent.type != syms.expr_stmt)
or (
# This condition tries to prevent removing non-optional brackets
# around a tuple, however, can be a bit overzealous so we provide
# and option to skip this check for `for` and `with` statements.
not remove_brackets_around_comma
and max_delimiter_priority_in_atom(node) >= COMMA_PRIORITY
)
or is_tuple_containing_walrus(node)
):
return False

max_delimiter_priority = max_delimiter_priority_in_atom(node)
# This condition tries to prevent removing non-optional brackets
# around a tuple, however, can be a bit overzealous so we provide
# and option to skip this check for `for` and `with` statements.
if not remove_brackets_around_comma and max_delimiter_priority >= COMMA_PRIORITY:
return False

if parent.type == syms.dictsetmaker and max_delimiter_priority != 0:
return False

if is_walrus_assignment(node):
if parent.type in [
syms.annassign,
Expand Down
2 changes: 1 addition & 1 deletion tests/data/cases/preview_long_dict_values_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def bar():
),
}
x = {
"foobar": 123 + 456,
"foobar": (123 + 456),
}
x = {
"foobar": (123) + 456,
Expand Down

0 comments on commit d39e79d

Please sign in to comment.