Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions manim/renderer/cairo_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@

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
Expand Down Expand Up @@ -60,7 +58,7 @@
def play(
self,
scene: Scene,
*args: Animation | Iterable[Animation] | types.GeneratorType[Animation],
*args: Animation | Mobject | _AnimationBuilder,
**kwargs,
):
# Reset skip_animations to the original state.
Expand Down
10 changes: 6 additions & 4 deletions manim/scene/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from ..camera.camera import Camera
from ..constants import *
from ..gui.gui import configure_pygui
from ..renderer.cairo_renderer import CairoRenderer

Check failure

Code scanning / CodeQL

Module-level cyclic import Error

'CairoRenderer' may not be defined if module
manim.renderer.cairo_renderer
is imported before module
manim.scene.scene
, as the
definition
of CairoRenderer occurs after the cyclic
import
of manim.scene.scene.
'CairoRenderer' may not be defined if module
manim.renderer.cairo_renderer
is imported before module
manim.scene.scene
, as the
definition
of CairoRenderer occurs after the cyclic
import
of manim.scene.scene.
'CairoRenderer' may not be defined if module
manim.renderer.cairo_renderer
is imported before module
manim.scene.scene
, as the
definition
of CairoRenderer occurs after the cyclic
import
of manim.scene.scene.
'CairoRenderer' may not be defined if module
manim.renderer.cairo_renderer
is imported before module
manim.scene.scene
, as the
definition
of CairoRenderer occurs after the cyclic
import
of manim.scene.scene.
'CairoRenderer' may not be defined if module
manim.renderer.cairo_renderer
is imported before module
manim.scene.scene
, as the
definition
of CairoRenderer occurs after the cyclic
import
of manim.scene.scene.
'CairoRenderer' may not be defined if module
manim.renderer.cairo_renderer
is imported before module
manim.scene.scene
, as the
definition
of CairoRenderer occurs after the cyclic
import
of manim.scene.scene.
from ..renderer.opengl_renderer import OpenGLRenderer
from ..renderer.shader import Object3D
from ..utils import opengl, space_ops
Expand All @@ -52,9 +52,11 @@
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."""
Expand Down Expand Up @@ -878,7 +880,7 @@

def compile_animations(
self,
*args: Animation | Iterable[Animation] | types.GeneratorType[Animation],
*args: Animation | Mobject | _AnimationBuilder,
**kwargs,
):
"""
Expand Down Expand Up @@ -1070,7 +1072,7 @@

def play(
self,
*args: Animation | Iterable[Animation] | types.GeneratorType[Animation],
*args: Animation | Mobject | _AnimationBuilder,
subcaption=None,
subcaption_duration=None,
subcaption_offset=0,
Expand Down Expand Up @@ -1205,7 +1207,7 @@

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
Expand Down
Loading