Skip to content

Commit

Permalink
Extend use of optional parentheses
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p committed Apr 28, 2021
1 parent 303a0b2 commit 4a4a3bc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/black/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6753,6 +6753,13 @@ def can_omit_invisible_parens(
# With more than one delimiter of a kind the optional parentheses read better.
return False

if (
max_priority >= LOGIC_PRIORITY
and bt.delimiter_count_with_priority(max_priority) > 0
):
# With at least one delimiter of kind LOGIC or above, optional parentheses are beter
return False

if max_priority == DOT_PRIORITY:
# A single stranded method call doesn't require optional parentheses.
return True
Expand Down

0 comments on commit 4a4a3bc

Please sign in to comment.