Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Fix typehint of :meth:`.Scene.play` to allow `.animate` (#4038)

Aarush Deshpande6abcc611b91f
diff --git a/manim/renderer/cairo_renderer.py b/manim/renderer/cairo_renderer.py
index 0b13fb863..6625a49eb 100644
--- a/manim/renderer/cairo_renderer.py
+++ b/manim/renderer/cairo_renderer.py
@@ -8,14 +8,12 @@ from manim.utils.hashing import get_hash_from_play_call
from .. import config, logger
from ..camera.camera import Camera
-from ..mobject.mobject import Mobject
+from ..mobject.mobject import Mobject, _AnimationBuilder
from ..scene.scene_file_writer import SceneFileWriter
from ..utils.exceptions import EndSceneEarlyException
from ..utils.iterables import list_update
if typing.TYPE_CHECKING:
- import types
- from collections.abc import Iterable
from typing import Any
from manim.animation.animation import Animation
@@ -60,7 +58,7 @@ class CairoRenderer:
def play(
self,
scene: Scene,
- *args: Animation | Iterable[Animation] | types.GeneratorType[Animation],
+ *args: Animation | Mobject | _AnimationBuilder,
**kwargs,
):
# Reset skip_animations to the original state.
diff --git a/manim/scene/scene.py b/manim/scene/scene.py
index e70c3beb1..bf8e526bf 100644
--- a/manim/scene/scene.py
+++ b/manim/scene/scene.py
@@ -52,9 +52,11 @@ from ..utils.file_ops import open_media_file
from ..utils.iterables import list_difference_update, list_update
if TYPE_CHECKING:
- from collections.abc import Iterable, Sequence
+ from collections.abc import Sequence
from typing import Callable
+ from manim.mobject.mobject import _AnimationBuilder
+
class RerunSceneHandler(FileSystemEventHandler):
"""A class to handle rerunning a Scene after the input file is modified."""
@@ -878,7 +880,7 @@ class Scene:
def compile_animations(
self,
- *args: Animation | Iterable[Animation] | types.GeneratorType[Animation],
+ *args: Animation | Mobject | _AnimationBuilder,
**kwargs,
):
"""
@@ -1070,7 +1072,7 @@ class Scene:
def play(
self,
- *args: Animation | Iterable[Animation] | types.GeneratorType[Animation],
+ *args: Animation | Mobject | _AnimationBuilder,
subcaption=None,
subcaption_duration=None,
subcaption_offset=0,
@@ -1205,7 +1207,7 @@ class Scene:
def compile_animation_data(
self,
- *animations: Animation | Iterable[Animation] | types.GeneratorType[Animation],
+ *animations: Animation | Mobject | _AnimationBuilder,
**play_kwargs,
):
"""Given a list of animations, compile the corresponding