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

Function replace_child

src/black/nodes.py:493–507  ·  view source on GitHub ↗

Side Effects: * If @old_child.parent is set, replace @old_child with @new_child in @old_child's underlying Node structure. OR * Otherwise, this function does nothing.

(old_child: LN, new_child: LN)

Source from the content-addressed store, hash-verified

491
492
493def replace_child(old_child: LN, new_child: LN) -> None:
494 """
495 Side Effects:
496 * If @old_child.parent is set, replace @old_child with @new_child in
497 @old_child's underlying Node structure.
498 OR
499 * Otherwise, this function does nothing.
500 """
501 parent = old_child.parent
502 if not parent:
503 return
504
505 child_idx = old_child.remove()
506 if child_idx is not None:
507 parent.insert_child(child_idx, new_child)
508
509
510def container_of(leaf: Leaf) -> LN:

Callers 5

append_leavesFunction · 0.90
do_transformMethod · 0.90

Calls 2

removeMethod · 0.80
insert_childMethod · 0.80

Tested by

no test coverage detected