mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Use typing_extensions to import Self for python versions <3.11
This commit is contained in:
parent
c062592684
commit
ab6a7df4af
14 changed files with 33 additions and 23 deletions
|
@ -11,8 +11,8 @@ from manimlib.utils.rate_functions import smooth
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Callable, List, Iterable, Self
|
||||
from manimlib.typing import ManimColor, Vect3
|
||||
from typing import Callable, List, Iterable
|
||||
from manimlib.typing import ManimColor, Vect3, Self
|
||||
|
||||
|
||||
class AnimatedBoundary(VGroup):
|
||||
|
|
|
@ -32,9 +32,9 @@ from manimlib.utils.space_ops import normalize
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Callable, Iterable, Sequence, Type, TypeVar, Optional, Self
|
||||
from typing import Callable, Iterable, Sequence, Type, TypeVar, Optional
|
||||
from manimlib.mobject.mobject import Mobject
|
||||
from manimlib.typing import ManimColor, Vect3, Vect3Array, VectN, RangeSpecifier
|
||||
from manimlib.typing import ManimColor, Vect3, Vect3Array, VectN, RangeSpecifier, Self
|
||||
|
||||
T = TypeVar("T", bound=Mobject)
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ from manimlib.utils.space_ops import rotation_matrix_transpose
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Iterable, Self, Optional
|
||||
from manimlib.typing import ManimColor, Vect3, Vect3Array
|
||||
from typing import Iterable, Optional
|
||||
from manimlib.typing import ManimColor, Vect3, Vect3Array, Self
|
||||
|
||||
|
||||
DEFAULT_DOT_RADIUS = 0.08
|
||||
|
|
|
@ -18,10 +18,10 @@ from manimlib.mobject.types.vectorized_mobject import VMobject
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Sequence, Self
|
||||
from typing import Sequence
|
||||
import numpy.typing as npt
|
||||
from manimlib.mobject.mobject import Mobject
|
||||
from manimlib.typing import ManimColor, Vect3
|
||||
from manimlib.typing import ManimColor, Vect3, Self
|
||||
|
||||
|
||||
VECTOR_LABEL_SCALE_FACTOR = 0.8
|
||||
|
|
|
@ -48,9 +48,9 @@ from manimlib.utils.space_ops import rotation_matrix_transpose
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Callable, Iterable, Iterator, Union, Tuple, Optional, Self
|
||||
from typing import Callable, Iterable, Iterator, Union, Tuple, Optional
|
||||
import numpy.typing as npt
|
||||
from manimlib.typing import ManimColor, Vect3, Vect4, Vect3Array, UniformDict
|
||||
from manimlib.typing import ManimColor, Vect3, Vect4, Vect3Array, UniformDict, Self
|
||||
from moderngl.context import Context
|
||||
|
||||
TimeBasedUpdater = Callable[["Mobject", float], "Mobject" | None]
|
||||
|
|
|
@ -11,8 +11,8 @@ from manimlib.mobject.types.vectorized_mobject import VMobject
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import TypeVar, Self
|
||||
from manimlib.typing import ManimColor, Vect3
|
||||
from typing import TypeVar
|
||||
from manimlib.typing import ManimColor, Vect3, Self
|
||||
|
||||
T = TypeVar("T", bound=VMobject)
|
||||
|
||||
|
|
|
@ -14,9 +14,9 @@ from manimlib.utils.customization import get_customization
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Sequence, Self
|
||||
from typing import Sequence
|
||||
from manimlib.mobject.mobject import Mobject
|
||||
from manimlib.typing import ManimColor
|
||||
from manimlib.typing import ManimColor, Self
|
||||
|
||||
|
||||
class SurroundingRectangle(Rectangle):
|
||||
|
|
|
@ -13,8 +13,8 @@ from typing import TYPE_CHECKING
|
|||
|
||||
if TYPE_CHECKING:
|
||||
import numpy.typing as npt
|
||||
from typing import Sequence, Tuple, Self
|
||||
from manimlib.typing import ManimColor, Vect3, Vect3Array
|
||||
from typing import Sequence, Tuple
|
||||
from manimlib.typing import ManimColor, Vect3, Vect3Array, Self
|
||||
|
||||
|
||||
DEFAULT_DOT_RADIUS = 0.05
|
||||
|
|
|
@ -10,8 +10,8 @@ from manimlib.utils.iterables import resize_with_interpolation
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Callable, Self
|
||||
from manimlib.typing import ManimColor, Vect3, Vect3Array, Vect4Array
|
||||
from typing import Callable
|
||||
from manimlib.typing import ManimColor, Vect3, Vect3Array, Vect4Array, Self
|
||||
|
||||
|
||||
class PMobject(Mobject):
|
||||
|
|
|
@ -17,10 +17,10 @@ from manimlib.utils.space_ops import cross
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Callable, Iterable, Sequence, Tuple, Self
|
||||
from typing import Callable, Iterable, Sequence, Tuple
|
||||
|
||||
from manimlib.camera.camera import Camera
|
||||
from manimlib.typing import ManimColor, Vect3, Vect3Array
|
||||
from manimlib.typing import ManimColor, Vect3, Vect3Array, Self
|
||||
|
||||
|
||||
class Surface(Mobject):
|
||||
|
|
|
@ -45,8 +45,8 @@ from manimlib.shader_wrapper import FillShaderWrapper
|
|||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Callable, Iterable, Tuple, Any, Self
|
||||
from manimlib.typing import ManimColor, Vect3, Vect4, Vect3Array, Vect4Array
|
||||
from typing import Callable, Iterable, Tuple, Any
|
||||
from manimlib.typing import ManimColor, Vect3, Vect4, Vect3Array, Vect4Array, Self
|
||||
from moderngl.context import Context
|
||||
|
||||
DEFAULT_STROKE_COLOR = GREY_A
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
from typing import Self
|
||||
from manimlib.mobject.mobject import Mobject
|
||||
from manimlib.utils.iterables import listify
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from manimlib.typing import Self
|
||||
|
||||
|
||||
class ValueTracker(Mobject):
|
||||
"""
|
||||
|
|
|
@ -6,6 +6,11 @@ if TYPE_CHECKING:
|
|||
import numpy as np
|
||||
import re
|
||||
|
||||
try:
|
||||
from typing import Self
|
||||
except ImportError:
|
||||
from typing_extensions import Self
|
||||
|
||||
# Abbreviations for a common types
|
||||
ManimColor = Union[str, Color, None]
|
||||
RangeSpecifier = Tuple[float, float, float] | Tuple[float, float]
|
||||
|
|
|
@ -22,4 +22,5 @@ skia-pathops
|
|||
svgelements>=1.8.1
|
||||
sympy
|
||||
tqdm
|
||||
typing-extensions; python_version < "3.11"
|
||||
validators
|
||||
|
|
Loading…
Add table
Reference in a new issue