Skip to content

Commit 6abcc61

Browse files
Fix typehint of :meth:.Scene.play to allow .animate (#4038)
1 parent 953888e commit 6abcc61

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

manim/renderer/cairo_renderer.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88

99
from .. import config, logger
1010
from ..camera.camera import Camera
11-
from ..mobject.mobject import Mobject
11+
from ..mobject.mobject import Mobject, _AnimationBuilder
1212
from ..scene.scene_file_writer import SceneFileWriter
1313
from ..utils.exceptions import EndSceneEarlyException
1414
from ..utils.iterables import list_update
1515

1616
if typing.TYPE_CHECKING:
17-
import types
18-
from collections.abc import Iterable
1917
from typing import Any
2018

2119
from manim.animation.animation import Animation
@@ -60,7 +58,7 @@ def init_scene(self, scene):
6058
def play(
6159
self,
6260
scene: Scene,
63-
*args: Animation | Iterable[Animation] | types.GeneratorType[Animation],
61+
*args: Animation | Mobject | _AnimationBuilder,
6462
**kwargs,
6563
):
6664
# Reset skip_animations to the original state.

manim/scene/scene.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@
5252
from ..utils.iterables import list_difference_update, list_update
5353

5454
if TYPE_CHECKING:
55-
from collections.abc import Iterable, Sequence
55+
from collections.abc import Sequence
5656
from typing import Callable
5757

58+
from manim.mobject.mobject import _AnimationBuilder
59+
5860

5961
class RerunSceneHandler(FileSystemEventHandler):
6062
"""A class to handle rerunning a Scene after the input file is modified."""
@@ -878,7 +880,7 @@ def get_moving_and_static_mobjects(self, animations):
878880

879881
def compile_animations(
880882
self,
881-
*args: Animation | Iterable[Animation] | types.GeneratorType[Animation],
883+
*args: Animation | Mobject | _AnimationBuilder,
882884
**kwargs,
883885
):
884886
"""
@@ -1070,7 +1072,7 @@ def get_run_time(self, animations: list[Animation]):
10701072

10711073
def play(
10721074
self,
1073-
*args: Animation | Iterable[Animation] | types.GeneratorType[Animation],
1075+
*args: Animation | Mobject | _AnimationBuilder,
10741076
subcaption=None,
10751077
subcaption_duration=None,
10761078
subcaption_offset=0,
@@ -1205,7 +1207,7 @@ def wait_until(self, stop_condition: Callable[[], bool], max_time: float = 60):
12051207

12061208
def compile_animation_data(
12071209
self,
1208-
*animations: Animation | Iterable[Animation] | types.GeneratorType[Animation],
1210+
*animations: Animation | Mobject | _AnimationBuilder,
12091211
**play_kwargs,
12101212
):
12111213
"""Given a list of animations, compile the corresponding

0 commit comments

Comments
 (0)