Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Fix typing of `Animation` (#3568)

Dan Davison9a84ec6a45f2
diff --git a/manim/animation/animation.py b/manim/animation/animation.py
index cb8fcaddf..90290eee3 100644
--- a/manim/animation/animation.py
+++ b/manim/animation/animation.py
@@ -18,6 +18,8 @@ __all__ = ["Animation", "Wait", "override_animation"]
from copy import deepcopy
from typing import TYPE_CHECKING, Callable, Iterable, Sequence
+from typing_extensions import Self
+
if TYPE_CHECKING:
from manim.scene.scene import Scene
@@ -112,7 +114,7 @@ class Animation:
*args,
use_override=True,
**kwargs,
- ):
+ ) -> Self:
if isinstance(mobject, Mobject) and use_override:
func = mobject.animation_override_for(cls)
if func is not None:
diff --git a/manim/typing.py b/manim/typing.py
index a6c3e2e1d..6f16bad90 100644
--- a/manim/typing.py
+++ b/manim/typing.py
@@ -561,7 +561,9 @@ Function types
# Due to current limitations
# (see https://github.com/python/mypy/issues/14656 / 8263),
# we don't specify the first argument type (Mobject).
-FunctionOverride: TypeAlias = Callable[..., None]
+# Nor are we able to specify the return type (Animation) since we cannot import
+# that here.
+FunctionOverride: TypeAlias = Callable
"""Function type returning an :class:`~.Animation` for the specified
:class:`~.Mobject`.
"""