A community-maintained Python framework for creating mathematical animations.
Add type annotations to `growing.py` (#4368)
Henrik Skov Midtibye339a68e54f4
diff --git a/manim/animation/animation.py b/manim/animation/animation.pyindex ab0cd66bb..0eab06843 100644--- a/manim/animation/animation.py+++ b/manim/animation/animation.py@@ -262,7 +262,7 @@ class Animation:):scene.add(self.mobject)- def create_starting_mobject(self) -> Mobject:+ def create_starting_mobject(self) -> Mobject | OpenGLMobject:# Keep track of where the mobject startsreturn self.mobject.copy()diff --git a/manim/animation/growing.py b/manim/animation/growing.pyindex d9f526c13..70a17ffaf 100644--- a/manim/animation/growing.py+++ b/manim/animation/growing.py@@ -33,14 +33,17 @@ __all__ = [import typing-import numpy as np-from ..animation.transform import Transformfrom ..constants import PIfrom ..utils.paths import spiral_pathif typing.TYPE_CHECKING:+ from typing import Any+from manim.mobject.geometry.line import Arrow+ from manim.mobject.opengl.opengl_mobject import OpenGLMobject+ from manim.typing import Point3DLike, Vector3DLike+ from manim.utils.color import ParsableManimColorfrom ..mobject.mobject import Mobject@@ -76,16 +79,20 @@ class GrowFromPoint(Transform):"""def __init__(- self, mobject: Mobject, point: np.ndarray, point_color: str = None, **kwargs- ) -> None:+ self,+ mobject: Mobject,+ point: Point3DLike,+ point_color: ParsableManimColor | None = None,+ **kwargs: Any,+ ):self.point = pointself.point_color = point_colorsuper().__init__(mobject, introducer=True, **kwargs)- def create_target(self) -> Mobject:+ def create_target(self) -> Mobject | OpenGLMobject:return self.mobject- def create_starting_mobject(self) -> Mobject:+ def create_starting_mobject(self) -> Mobject | OpenGLMobject:start = super().create_starting_mobject()start.scale(0)start.move_to(self.point)@@ -118,7 +125,12 @@ class GrowFromCenter(GrowFromPoint):"""- def __init__(self, mobject: Mobject, point_color: str = None, **kwargs) -> None:+ def __init__(+ self,+ mobject: Mobject,+ point_color: ParsableManimColor | None = None,+ **kwargs: Any,+ ):point = mobject.get_center()super().__init__(mobject, point, point_color=point_color, **kwargs)@@ -153,8 +165,12 @@ class GrowFromEdge(GrowFromPoint):"""def __init__(- self, mobject: Mobject, edge: np.ndarray, point_color: str = None, **kwargs- ) -> None:+ self,+ mobject: Mobject,+ edge: Vector3DLike,+ point_color: ParsableManimColor | None = None,+ **kwargs: Any,+ ):point = mobject.get_critical_point(edge)super().__init__(mobject, point, point_color=point_color, **kwargs)@@ -183,11 +199,13 @@ class GrowArrow(GrowFromPoint):"""- def __init__(self, arrow: Arrow, point_color: str = None, **kwargs) -> None:+ def __init__(+ self, arrow: Arrow, point_color: ParsableManimColor | None = None, **kwargs: Any+ ):point = arrow.get_start()super().__init__(arrow, point, point_color=point_color, **kwargs)- def create_starting_mobject(self) -> Mobject:+ def create_starting_mobject(self) -> Mobject | OpenGLMobject:start_arrow = self.mobject.copy()start_arrow.scale(0, scale_tips=True, about_point=self.point)if self.point_color:@@ -224,8 +242,12 @@ class SpinInFromNothing(GrowFromCenter):"""def __init__(- self, mobject: Mobject, angle: float = PI / 2, point_color: str = None, **kwargs- ) -> None:+ self,+ mobject: Mobject,+ angle: float = PI / 2,+ point_color: ParsableManimColor | None = None,+ **kwargs: Any,+ ):self.angle = anglesuper().__init__(mobject, path_func=spiral_path(angle), point_color=point_color, **kwargsdiff --git a/mypy.ini b/mypy.iniindex 4b2758102..4a70f08c2 100644--- a/mypy.ini+++ b/mypy.ini@@ -57,9 +57,6 @@ ignore_errors = True[mypy-manim.animation.creation]ignore_errors = True-[mypy-manim.animation.growing]-ignore_errors = True-[mypy-manim.animation.movement]ignore_errors = True