@@ -33,7 +33,7 @@ def __init__(
33
33
lag_ratio : float = DEFAULT_ANIMATION_LAG_RATIO ,
34
34
rate_func : Callable [[float ], float ] = smooth ,
35
35
name : str = "" ,
36
- # Does this animation add or remove a mobject form the screen
36
+ # Does this animation add or remove a mobject from the screen
37
37
remover : bool = False ,
38
38
# What to enter into the update function upon completion
39
39
final_alpha_value : float = 1.0 ,
@@ -42,6 +42,7 @@ def __init__(
42
42
# updating, call mobject.suspend_updating() before the animation
43
43
suspend_mobject_updating : bool = False ,
44
44
):
45
+ self ._validate_input_type (mobject )
45
46
self .mobject = mobject
46
47
self .run_time = run_time
47
48
self .time_span = time_span
@@ -52,7 +53,9 @@ def __init__(
52
53
self .lag_ratio = lag_ratio
53
54
self .suspend_mobject_updating = suspend_mobject_updating
54
55
55
- assert isinstance (mobject , Mobject )
56
+ def _validate_input_type (self , mobject : Mobject ) -> None :
57
+ if not isinstance (mobject , Mobject ):
58
+ raise TypeError ("Animation only works for Mobjects." )
56
59
57
60
def __str__ (self ) -> str :
58
61
return self .name
0 commit comments