MLC115: Scene.remove(child) undone by re-adding the surviving parent¶
qual reports MLC115 when Scene.remove(child) removes a child
whose parent group keeps it in submobjects, and that parent later
definitely returns to the scene (an explicit add, or the auto-add of a
play). Scene.remove restructures only the scene root list
(scene.py restructure_mobjects); the parent's own child list is not
edited, so the removed child reappears with the parent.
- Default severity:
warning - Minimum confidence:
high - Implementation phase:
2 - Fix: none (removing the child from the parent too is suggested)
A structural parent.remove(child) between the removal and the re-add,
a removal of the whole parent (no surviving parents), an explicit re-add
of the child itself, and branch-dependent re-adds all stay silent.
Wrong¶
class Demo(Scene):
def construct(self):
square, dot = Square(), Dot()
group = VGroup(square, dot)
self.add(group)
self.remove(dot)
self.play(FadeIn(group)) # dot reappears