Skip to content

Commit bf00f64

Browse files
committed
Cannot shift a node before the root
1 parent 803ac50 commit bf00f64

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

udapi/core/node.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,8 @@ def shift_after_node(self, reference_node, without_children=False, skip_if_desce
662662

663663
def shift_before_node(self, reference_node, without_children=False, skip_if_descendant=False):
664664
"""Shift this node before the reference_node."""
665+
if reference_node.is_root():
666+
raise ValueError(f'Cannot shift a node before the root ({reference_node})')
665667
if not without_children and reference_node.is_descendant_of(self):
666668
if skip_if_descendant:
667669
return
@@ -690,6 +692,8 @@ def shift_before_subtree(self, reference_node, without_children=0, skip_if_desce
690692
Args:
691693
without_children: shift just this node without its subtree?
692694
"""
695+
if reference_node.is_root():
696+
raise ValueError(f'Cannot shift a node before the root ({reference_node})')
693697
if not without_children and reference_node.is_descendant_of(self):
694698
if skip_if_descendant:
695699
return

0 commit comments

Comments
 (0)