MCPcopy
hub / github.com/psf/black / append_to_line

Function append_to_line

src/black/linegen.py:1396–1407  ·  view source on GitHub ↗

Append `leaf` to current line or to new line if appending impossible.

(leaf: Leaf)

Source from the content-addressed store, hash-verified

1394 trailing_comma_safe = True
1395
1396 def append_to_line(leaf: Leaf) -> Iterator[Line]:
1397 """Append `leaf` to current line or to new line if appending impossible."""
1398 nonlocal current_line
1399 try:
1400 current_line.append_safe(leaf, preformatted=True)
1401 except ValueError:
1402 yield current_line
1403
1404 current_line = Line(
1405 mode=line.mode, depth=line.depth, inside_brackets=line.inside_brackets
1406 )
1407 current_line.append(leaf)
1408
1409 def append_comments(leaf: Leaf) -> Iterator[Line]:
1410 for comment_after in line.comments_after(leaf):

Callers 3

append_commentsFunction · 0.85
delimiter_splitFunction · 0.85
standalone_comment_splitFunction · 0.85

Calls 3

append_safeMethod · 0.95
appendMethod · 0.95
LineClass · 0.90

Tested by

no test coverage detected