Skip to content

Refactor imports from collections.abc, typing and typing_extensions for Python 3.9 #4353

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .github/scripts/ci_build_cairo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import sys
import tarfile
import tempfile
import typing
import urllib.request
from collections.abc import Generator
from contextlib import contextmanager
from pathlib import Path
from sys import stdout
Expand Down Expand Up @@ -67,7 +67,7 @@ def run_command(command, cwd=None, env=None):


@contextmanager
def gha_group(title: str) -> typing.Generator:
def gha_group(title: str) -> Generator:
if not is_ci():
yield
return
Expand Down
4 changes: 2 additions & 2 deletions manim/animation/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
__all__ = ["Animation", "Wait", "Add", "override_animation"]


from collections.abc import Iterable, Sequence
from collections.abc import Callable, Iterable, Sequence
from copy import deepcopy
from functools import partialmethod
from typing import TYPE_CHECKING, Any, Callable
from typing import TYPE_CHECKING, Any

from typing_extensions import Self

Expand Down
6 changes: 3 additions & 3 deletions manim/animation/changing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

__all__ = ["AnimatedBoundary", "TracedPath"]

from collections.abc import Sequence
from typing import Callable
from collections.abc import Callable, Sequence
from typing import Any

from typing_extensions import Any, Self
from typing_extensions import Self

from manim.mobject.mobject import Mobject
from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL
Expand Down
4 changes: 2 additions & 2 deletions manim/animation/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from __future__ import annotations

import types
from collections.abc import Iterable, Sequence
from typing import TYPE_CHECKING, Callable
from collections.abc import Callable, Iterable, Sequence
from typing import TYPE_CHECKING

import numpy as np

Expand Down
4 changes: 2 additions & 2 deletions manim/animation/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def construct(self):


import itertools as it
from collections.abc import Iterable, Sequence
from typing import TYPE_CHECKING, Callable
from collections.abc import Callable, Iterable, Sequence
from typing import TYPE_CHECKING

import numpy as np

Expand Down
3 changes: 2 additions & 1 deletion manim/animation/fading.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ def construct(self):
"FadeIn",
]

from typing import Any

import numpy as np
from typing_extensions import Any

from manim.mobject.opengl.opengl_mobject import OpenGLMobject

Expand Down
4 changes: 2 additions & 2 deletions manim/animation/growing.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ def construct(self):
"SpinInFromNothing",
]

import typing
from typing import TYPE_CHECKING

import numpy as np

from ..animation.transform import Transform
from ..constants import PI
from ..utils.paths import spiral_path

if typing.TYPE_CHECKING:
if TYPE_CHECKING:
from manim.mobject.geometry.line import Arrow

from ..mobject.mobject import Mobject
Expand Down
3 changes: 1 addition & 2 deletions manim/animation/indication.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ def construct(self):
"Blink",
]

from collections.abc import Iterable
from typing import Callable
from collections.abc import Callable, Iterable

import numpy as np

Expand Down
7 changes: 3 additions & 4 deletions manim/animation/numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
__all__ = ["ChangingDecimal", "ChangeDecimalToValue"]


import typing

from typing_extensions import Any
from collections.abc import Callable
from typing import Any

from manim.mobject.text.numbers import DecimalNumber

Expand Down Expand Up @@ -54,7 +53,7 @@ def construct(self):
def __init__(
self,
decimal_mob: DecimalNumber,
number_update_func: typing.Callable[[float], float],
number_update_func: Callable[[float], float],
suspend_mobject_updating: bool = False,
**kwargs: Any,
) -> None:
Expand Down
5 changes: 2 additions & 3 deletions manim/animation/rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

__all__ = ["Rotating", "Rotate"]

from collections.abc import Sequence
from typing import TYPE_CHECKING, Callable
from collections.abc import Callable, Sequence
from typing import TYPE_CHECKING, Any

import numpy as np
from typing_extensions import Any

from ..animation.animation import Animation
from ..animation.transform import Transform
Expand Down
3 changes: 2 additions & 1 deletion manim/animation/speedmodifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

import inspect
import types
from typing import TYPE_CHECKING, Callable
from collections.abc import Callable
from typing import TYPE_CHECKING

from numpy import piecewise

Expand Down
4 changes: 2 additions & 2 deletions manim/animation/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

import inspect
import types
from collections.abc import Iterable, Sequence
from typing import TYPE_CHECKING, Any, Callable
from collections.abc import Callable, Iterable, Sequence
from typing import TYPE_CHECKING, Any

import numpy as np

Expand Down
3 changes: 2 additions & 1 deletion manim/animation/updaters/mobject_update_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@


import inspect
from typing import TYPE_CHECKING, Callable
from collections.abc import Callable
from typing import TYPE_CHECKING

import numpy as np

Expand Down
8 changes: 3 additions & 5 deletions manim/animation/updaters/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@


import operator as op
import typing
from typing import Callable

from typing_extensions import Any
from collections.abc import Callable
from typing import TYPE_CHECKING, Any

from manim.animation.animation import Animation

if typing.TYPE_CHECKING:
if TYPE_CHECKING:
from manim.mobject.mobject import Mobject


Expand Down
4 changes: 2 additions & 2 deletions manim/camera/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import itertools as it
import operator as op
import pathlib
from collections.abc import Iterable
from collections.abc import Callable, Iterable
from functools import reduce
from typing import Any, Callable
from typing import Any

import cairo
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion manim/camera/three_d_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__all__ = ["ThreeDCamera"]


from typing import Callable
from collections.abc import Callable

import numpy as np

Expand Down
3 changes: 2 additions & 1 deletion manim/cli/checkhealth/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

import os
import shutil
from typing import Callable, Protocol, cast
from collections.abc import Callable
from typing import Protocol, cast

__all__ = ["HEALTH_CHECKS"]

Expand Down
3 changes: 2 additions & 1 deletion manim/cli/default_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
from __future__ import annotations

import warnings
from typing import TYPE_CHECKING, Any, Callable
from collections.abc import Callable
from typing import TYPE_CHECKING, Any

import cloup

Expand Down
2 changes: 1 addition & 1 deletion manim/mobject/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
]


from typing_extensions import Any
from typing import Any

from manim.mobject.geometry.polygram import Rectangle

Expand Down
3 changes: 1 addition & 2 deletions manim/mobject/geometry/arc.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def construct(self):

import itertools
import warnings
from typing import TYPE_CHECKING, cast
from typing import TYPE_CHECKING, Any, cast

import numpy as np
from typing_extensions import Self
Expand All @@ -64,7 +64,6 @@ def construct(self):

if TYPE_CHECKING:
from collections.abc import Iterable
from typing import Any

import manim.mobject.geometry.tips as tips
from manim.mobject.mobject import Mobject
Expand Down
4 changes: 1 addition & 3 deletions manim/mobject/geometry/boolean_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any

import numpy as np
from pathops import Path as SkiaPath
Expand All @@ -13,8 +13,6 @@
from manim.mobject.types.vectorized_mobject import VMobject

if TYPE_CHECKING:
from typing import Any

from manim.typing import Point2DLike_Array, Point3D_Array, Point3DLike_Array

from ...constants import RendererType
Expand Down
4 changes: 1 addition & 3 deletions manim/mobject/geometry/labeled.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

__all__ = ["Label", "LabeledLine", "LabeledArrow", "LabeledPolygram"]

from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any

import numpy as np

Expand All @@ -22,8 +22,6 @@
from manim.utils.polylabel import polylabel

if TYPE_CHECKING:
from typing import Any

from manim.typing import Point3DLike_Array


Expand Down
6 changes: 2 additions & 4 deletions manim/mobject/geometry/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"RightAngle",
]

from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any, Literal

import numpy as np

Expand All @@ -30,9 +30,7 @@
from manim.utils.space_ops import angle_of_vector, line_intersection, normalize

if TYPE_CHECKING:
from typing import Any

from typing_extensions import Literal, Self, TypeAlias
from typing_extensions import Self, TypeAlias

from manim.typing import Point2DLike, Point3D, Point3DLike, Vector3D
from manim.utils.color import ParsableManimColor
Expand Down
4 changes: 1 addition & 3 deletions manim/mobject/geometry/polygram.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


from math import ceil
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any, Literal

import numpy as np

Expand All @@ -32,8 +32,6 @@
from manim.utils.space_ops import angle_between_vectors, normalize, regular_vertices

if TYPE_CHECKING:
from typing import Any, Literal

import numpy.typing as npt
from typing_extensions import Self

Expand Down
4 changes: 1 addition & 3 deletions manim/mobject/geometry/tips.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"StealthTip",
]

from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any

import numpy as np

Expand All @@ -25,8 +25,6 @@
from manim.utils.space_ops import angle_of_vector

if TYPE_CHECKING:
from typing import Any

from manim.typing import Point3D, Vector3D


Expand Down
4 changes: 2 additions & 2 deletions manim/mobject/graphing/coordinate_systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

import fractions as fr
import numbers
from collections.abc import Iterable, Sequence
from typing import TYPE_CHECKING, Any, Callable, TypeVar, overload
from collections.abc import Callable, Iterable, Sequence
from typing import TYPE_CHECKING, Any, TypeVar, overload

import numpy as np
from typing_extensions import Self
Expand Down
4 changes: 2 additions & 2 deletions manim/mobject/graphing/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
__all__ = ["ParametricFunction", "FunctionGraph", "ImplicitFunction"]


from collections.abc import Iterable, Sequence
from typing import TYPE_CHECKING, Callable
from collections.abc import Callable, Iterable, Sequence
from typing import TYPE_CHECKING

import numpy as np
from isosurfaces import plot_isoline
Expand Down
4 changes: 2 additions & 2 deletions manim/mobject/graphing/number_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
__all__ = ["NumberLine", "UnitInterval"]


from collections.abc import Iterable, Sequence
from typing import TYPE_CHECKING, Callable
from collections.abc import Callable, Iterable, Sequence
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from manim.mobject.geometry.tips import ArrowTip
Expand Down
3 changes: 2 additions & 1 deletion manim/mobject/logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

__all__ = ["ManimBanner"]

from typing import Any

import svgelements as se
from typing_extensions import Any

from manim.animation.updaters.update import UpdateFromAlphaFunc
from manim.mobject.geometry.arc import Circle
Expand Down
Loading