A community-maintained Python framework for creating mathematical animations.
Fix some typehints in mobject.py (#3668)
adeshpandef8e3408f9e58
diff --git a/manim/animation/speedmodifier.py b/manim/animation/speedmodifier.pyindex 9df1c9f01..63b9b2e5b 100644--- a/manim/animation/speedmodifier.py+++ b/manim/animation/speedmodifier.py@@ -4,15 +4,18 @@ from __future__ import annotationsimport inspectimport types-from typing import Callable+from typing import TYPE_CHECKING, Callablefrom numpy import piecewisefrom ..animation.animation import Animation, Wait, prepare_animationfrom ..animation.composition import AnimationGroup-from ..mobject.mobject import Mobject, Updater, _AnimationBuilder+from ..mobject.mobject import Mobject, _AnimationBuilderfrom ..scene.scene import Scene+if TYPE_CHECKING:+ from ..mobject.mobject import Updater+__all__ = ["ChangeSpeed"]diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.pyindex ce5c97119..73b1920ff 100644--- a/manim/mobject/mobject.py+++ b/manim/mobject/mobject.py@@ -16,10 +16,9 @@ import typesimport warningsfrom functools import partialmethod, reducefrom pathlib import Path-from typing import TYPE_CHECKING, Callable, Iterable, Literal, TypeVar, Union+from typing import TYPE_CHECKING, Callable, Iterable, Literalimport numpy as np-from typing_extensions import Self, TypeAliasfrom manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL@@ -39,14 +38,9 @@ from ..utils.iterables import list_update, remove_list_redundanciesfrom ..utils.paths import straight_pathfrom ..utils.space_ops import angle_between_vectors, normalize, rotation_matrix-# TODO: Explain array_attrs--TimeBasedUpdater: TypeAlias = Callable[["Mobject", float], None]-NonTimeBasedUpdater: TypeAlias = Callable[["Mobject"], None]-Updater: TypeAlias = Union[NonTimeBasedUpdater, TimeBasedUpdater]-T = TypeVar("T", bound="Mobject")-if TYPE_CHECKING:+ from typing_extensions import Self, TypeAlias+from manim.typing import (FunctionOverride,Image,@@ -61,6 +55,10 @@ if TYPE_CHECKING:from ..animation.animation import Animation+ TimeBasedUpdater: TypeAlias = Callable[["Mobject", float], object]+ NonTimeBasedUpdater: TypeAlias = Callable[["Mobject"], object]+ Updater: TypeAlias = NonTimeBasedUpdater | TimeBasedUpdater+class Mobject:"""Mathematical Object: base class for objects that can be displayed on screen.@@ -237,7 +235,7 @@ class Mobject:cls.__init__ = cls._original__init__@property- def animate(self: T) -> _AnimationBuilder | T:+ def animate(self) -> _AnimationBuilder | Self:"""Used to animate the application of any method of :code:`self`.Any method called on :code:`animate` is converted to an animation of applying@@ -2926,7 +2924,7 @@ class Mobject:self,z_index_value: float,family: bool = True,- ) -> T:+ ) -> Self:"""Sets the :class:`~.Mobject`'s :attr:`z_index` to the value specified in `z_index_value`.Parameters