Skip to content

Commit

Permalink
Fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Booome committed Jan 14, 2024
1 parent b51f2c9 commit 8009888
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/black/linegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ def _maybe_split_omitting_optional_parens(
and not line.is_import
# and we can actually remove the parens
and can_omit_invisible_parens(rhs, mode.line_length)
and (Preview.improve_call_chain not in mode or not rhs.body.is_call_chain)
and not (Preview.improve_call_chain in mode and rhs.body.is_call_chain)
):
omit = {id(rhs.closing_bracket), *omit}
try:
Expand Down Expand Up @@ -1182,7 +1182,7 @@ def delimiter_split(
raise CannotSplit("No delimiters found") from None

if (
Preview.improve_call_chain not in mode
not (Preview.improve_call_chain in mode and line.is_call_chain)
and delimiter_priority == DOT_PRIORITY
and bt.delimiter_count_with_priority(delimiter_priority) == 1
):
Expand Down
33 changes: 21 additions & 12 deletions src/black/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,19 +225,28 @@ def is_call_chain(self) -> bool:
"""Is the line a call chain"""
if self.comments:
return False
count = 0
line_node = self.leaves[0].parent
if line_node:
for child in line_node.children:
if (
child.type == syms.trailer
and child.children[0].type == token.DOT
and child.next_sibling
and child.next_sibling.type == syms.trailer
and child.next_sibling.children[0].type in OPENING_BRACKETS
):
count += 1
return count > 1
if not line_node:
return False
depth = 2 if line_node.type == syms.old_comp_for else 1

def get_call_count(node: Node, depth: int) -> int:
count = 0
for child in node.children:
if isinstance(child, Node):
if (
child.type == syms.trailer
and child.children[0].type == token.DOT
and child.next_sibling
and child.next_sibling.type == syms.trailer
and child.next_sibling.children[0].type in OPENING_BRACKETS
):
count += 1
elif depth - 1 > 0:
count += get_call_count(child, depth - 1)
return count

return get_call_count(line_node, depth) > 1

@property
def opens_block(self) -> bool:
Expand Down

0 comments on commit 8009888

Please sign in to comment.