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