Simplify Line.contains_multiline_strings method (#1267)
This commit is contained in:
parent
383857273c
commit
ce14fa8b49
12
black.py
12
black.py
@ -760,11 +760,9 @@ def format_str(src_contents: str, *, mode: FileMode) -> FileContent:
|
|||||||
if supports_feature(versions, feature)
|
if supports_feature(versions, feature)
|
||||||
}
|
}
|
||||||
for current_line in lines.visit(src_node):
|
for current_line in lines.visit(src_node):
|
||||||
for _ in range(after):
|
dst_contents.append(str(empty_line) * after)
|
||||||
dst_contents.append(str(empty_line))
|
|
||||||
before, after = elt.maybe_empty_lines(current_line)
|
before, after = elt.maybe_empty_lines(current_line)
|
||||||
for _ in range(before):
|
dst_contents.append(str(empty_line) * before)
|
||||||
dst_contents.append(str(empty_line))
|
|
||||||
for line in split_line(
|
for line in split_line(
|
||||||
current_line, line_length=mode.line_length, features=split_line_features
|
current_line, line_length=mode.line_length, features=split_line_features
|
||||||
):
|
):
|
||||||
@ -1449,11 +1447,7 @@ def contains_unsplittable_type_ignore(self) -> bool:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def contains_multiline_strings(self) -> bool:
|
def contains_multiline_strings(self) -> bool:
|
||||||
for leaf in self.leaves:
|
return any(is_multiline_string(leaf) for leaf in self.leaves)
|
||||||
if is_multiline_string(leaf):
|
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
def maybe_remove_trailing_comma(self, closing: Leaf) -> bool:
|
def maybe_remove_trailing_comma(self, closing: Leaf) -> bool:
|
||||||
"""Remove trailing comma if there is one and it's safe."""
|
"""Remove trailing comma if there is one and it's safe."""
|
||||||
|
Loading…
Reference in New Issue
Block a user