Skip to content

Commit e339a68

Browse files
Add type annotations to growing.py (#4368)
Co-authored-by: Francisco Manríquez Novoa <[email protected]>
1 parent c887b51 commit e339a68

File tree

3 files changed

+36
-17
lines changed

3 files changed

+36
-17
lines changed

manim/animation/animation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def _setup_scene(self, scene: Scene) -> None:
262262
):
263263
scene.add(self.mobject)
264264

265-
def create_starting_mobject(self) -> Mobject:
265+
def create_starting_mobject(self) -> Mobject | OpenGLMobject:
266266
# Keep track of where the mobject starts
267267
return self.mobject.copy()
268268

manim/animation/growing.py

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,17 @@ def construct(self):
3333

3434
import typing
3535

36-
import numpy as np
37-
3836
from ..animation.transform import Transform
3937
from ..constants import PI
4038
from ..utils.paths import spiral_path
4139

4240
if typing.TYPE_CHECKING:
41+
from typing import Any
42+
4343
from manim.mobject.geometry.line import Arrow
44+
from manim.mobject.opengl.opengl_mobject import OpenGLMobject
45+
from manim.typing import Point3DLike, Vector3DLike
46+
from manim.utils.color import ParsableManimColor
4447

4548
from ..mobject.mobject import Mobject
4649

@@ -76,16 +79,20 @@ def construct(self):
7679
"""
7780

7881
def __init__(
79-
self, mobject: Mobject, point: np.ndarray, point_color: str = None, **kwargs
80-
) -> None:
82+
self,
83+
mobject: Mobject,
84+
point: Point3DLike,
85+
point_color: ParsableManimColor | None = None,
86+
**kwargs: Any,
87+
):
8188
self.point = point
8289
self.point_color = point_color
8390
super().__init__(mobject, introducer=True, **kwargs)
8491

85-
def create_target(self) -> Mobject:
92+
def create_target(self) -> Mobject | OpenGLMobject:
8693
return self.mobject
8794

88-
def create_starting_mobject(self) -> Mobject:
95+
def create_starting_mobject(self) -> Mobject | OpenGLMobject:
8996
start = super().create_starting_mobject()
9097
start.scale(0)
9198
start.move_to(self.point)
@@ -118,7 +125,12 @@ def construct(self):
118125
119126
"""
120127

121-
def __init__(self, mobject: Mobject, point_color: str = None, **kwargs) -> None:
128+
def __init__(
129+
self,
130+
mobject: Mobject,
131+
point_color: ParsableManimColor | None = None,
132+
**kwargs: Any,
133+
):
122134
point = mobject.get_center()
123135
super().__init__(mobject, point, point_color=point_color, **kwargs)
124136

@@ -153,8 +165,12 @@ def construct(self):
153165
"""
154166

155167
def __init__(
156-
self, mobject: Mobject, edge: np.ndarray, point_color: str = None, **kwargs
157-
) -> None:
168+
self,
169+
mobject: Mobject,
170+
edge: Vector3DLike,
171+
point_color: ParsableManimColor | None = None,
172+
**kwargs: Any,
173+
):
158174
point = mobject.get_critical_point(edge)
159175
super().__init__(mobject, point, point_color=point_color, **kwargs)
160176

@@ -183,11 +199,13 @@ def construct(self):
183199
184200
"""
185201

186-
def __init__(self, arrow: Arrow, point_color: str = None, **kwargs) -> None:
202+
def __init__(
203+
self, arrow: Arrow, point_color: ParsableManimColor | None = None, **kwargs: Any
204+
):
187205
point = arrow.get_start()
188206
super().__init__(arrow, point, point_color=point_color, **kwargs)
189207

190-
def create_starting_mobject(self) -> Mobject:
208+
def create_starting_mobject(self) -> Mobject | OpenGLMobject:
191209
start_arrow = self.mobject.copy()
192210
start_arrow.scale(0, scale_tips=True, about_point=self.point)
193211
if self.point_color:
@@ -224,8 +242,12 @@ def construct(self):
224242
"""
225243

226244
def __init__(
227-
self, mobject: Mobject, angle: float = PI / 2, point_color: str = None, **kwargs
228-
) -> None:
245+
self,
246+
mobject: Mobject,
247+
angle: float = PI / 2,
248+
point_color: ParsableManimColor | None = None,
249+
**kwargs: Any,
250+
):
229251
self.angle = angle
230252
super().__init__(
231253
mobject, path_func=spiral_path(angle), point_color=point_color, **kwargs

mypy.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ ignore_errors = True
5757
[mypy-manim.animation.creation]
5858
ignore_errors = True
5959

60-
[mypy-manim.animation.growing]
61-
ignore_errors = True
62-
6360
[mypy-manim.animation.movement]
6461
ignore_errors = True
6562

0 commit comments

Comments
 (0)