Skip to content
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

Fix some typehints in mobject.py #3668

Merged
merged 4 commits into from
Apr 20, 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
7 changes: 5 additions & 2 deletions manim/animation/speedmodifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@

import inspect
import types
from typing import Callable
from typing import TYPE_CHECKING, Callable

from numpy import piecewise

from ..animation.animation import Animation, Wait, prepare_animation
from ..animation.composition import AnimationGroup
from ..mobject.mobject import Mobject, Updater, _AnimationBuilder
from ..mobject.mobject import Mobject, _AnimationBuilder
from ..scene.scene import Scene

if TYPE_CHECKING:
from ..mobject.mobject import Updater

__all__ = ["ChangeSpeed"]


Expand Down
20 changes: 9 additions & 11 deletions manim/mobject/mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
import warnings
from functools import partialmethod, reduce
from pathlib import Path
from typing import TYPE_CHECKING, Callable, Iterable, Literal, TypeVar, Union
from typing import TYPE_CHECKING, Callable, Iterable, Literal

import numpy as np
from typing_extensions import Self, TypeAlias

from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL

Expand All @@ -39,14 +38,9 @@
from ..utils.paths import straight_path
from ..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,
Expand All @@ -61,6 +55,10 @@

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.
Expand Down Expand Up @@ -237,7 +235,7 @@ def construct(self):
cls.__init__ = cls._original__init__

@property
def animate(self: T) -> _AnimationBuilder | T:
def animate(self) -> _AnimationBuilder | Self:
JasonGrace2282 marked this conversation as resolved.
Show resolved Hide resolved
"""Used to animate the application of any method of :code:`self`.

Any method called on :code:`animate` is converted to an animation of applying
Expand Down Expand Up @@ -2926,7 +2924,7 @@ def set_z_index(
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
Expand Down
Loading