Skip to content

Commit 3b496ea

Browse files
Add helpful hints to VGroup.add() error message (#3561)
* Improve VGroup creation error message * Use .__name__ for the type Co-authored-by: Jason Grace <[email protected]> --------- Co-authored-by: Jason Grace <[email protected]>
1 parent 286f366 commit 3b496ea

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

manim/mobject/types/vectorized_mobject.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,8 +2003,14 @@ def construct(self):
20032003
(gr-circle_red).animate.shift(RIGHT)
20042004
)
20052005
"""
2006-
if not all(isinstance(m, (VMobject, OpenGLVMobject)) for m in vmobjects):
2007-
raise TypeError("All submobjects must be of type VMobject")
2006+
for m in vmobjects:
2007+
if not isinstance(m, (VMobject, OpenGLVMobject)):
2008+
raise TypeError(
2009+
f"All submobjects of {self.__class__.__name__} must be of type VMobject. "
2010+
f"Got {repr(m)} ({type(m).__name__}) instead. "
2011+
"You can try using `Group` instead."
2012+
)
2013+
20082014
return super().add(*vmobjects)
20092015

20102016
def __add__(self, vmobject: VMobject) -> Self:

0 commit comments

Comments
 (0)