Skip to content

Commit 203a536

Browse files
Use --py39-plus in pre-commit (#3761)
* Use --py39-plus in pre-commit * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fix indication.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 1f249e4 commit 203a536

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+95
-82
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ repos:
2828
hooks:
2929
- id: pyupgrade
3030
name: Update code to new python versions
31-
args: [--py37-plus]
31+
args: [--py39-plus]
3232
- repo: https://github.com/pre-commit/pygrep-hooks
3333
rev: v1.10.0
3434
hooks:

manim/_config/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
from __future__ import annotations
44

55
import logging
6+
from collections.abc import Generator
67
from contextlib import contextmanager
7-
from typing import Any, Generator
8+
from typing import Any
89

910
from .cli_colors import parse_cli_ctx
1011
from .logger_utils import make_logger

manim/_config/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
import os
2121
import re
2222
import sys
23-
from collections.abc import Mapping, MutableMapping
23+
from collections.abc import Iterable, Iterator, Mapping, MutableMapping
2424
from pathlib import Path
25-
from typing import TYPE_CHECKING, Any, ClassVar, Iterable, Iterator, NoReturn
25+
from typing import TYPE_CHECKING, Any, ClassVar, NoReturn
2626

2727
import numpy as np
2828

manim/animation/animation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
__all__ = ["Animation", "Wait", "override_animation"]
1515

1616

17+
from collections.abc import Iterable, Sequence
1718
from copy import deepcopy
18-
from typing import TYPE_CHECKING, Callable, Iterable, Sequence
19+
from typing import TYPE_CHECKING, Callable
1920

2021
from typing_extensions import Self
2122

manim/animation/composition.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
from __future__ import annotations
44

55
import types
6-
from typing import TYPE_CHECKING, Callable, Iterable, Sequence
6+
from collections.abc import Iterable, Sequence
7+
from typing import TYPE_CHECKING, Callable
78

89
import numpy as np
910

manim/animation/creation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ def construct(self):
7676

7777

7878
import itertools as it
79-
from typing import TYPE_CHECKING, Callable, Iterable, Sequence
79+
from collections.abc import Iterable, Sequence
80+
from typing import TYPE_CHECKING, Callable
8081

8182
import numpy as np
8283

manim/animation/indication.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def construct(self):
2525
2626
"""
2727

28+
from __future__ import annotations
29+
2830
__all__ = [
2931
"FocusOn",
3032
"Indicate",
@@ -37,7 +39,8 @@ def construct(self):
3739
"Blink",
3840
]
3941

40-
from typing import Callable, Iterable, Optional, Tuple, Type, Union
42+
from collections.abc import Iterable
43+
from typing import Callable
4144

4245
import numpy as np
4346

@@ -93,11 +96,11 @@ def construct(self):
9396

9497
def __init__(
9598
self,
96-
focus_point: Union[np.ndarray, Mobject],
99+
focus_point: np.ndarray | Mobject,
97100
opacity: float = 0.2,
98101
color: str = GREY,
99102
run_time: float = 2,
100-
**kwargs
103+
**kwargs,
101104
) -> None:
102105
self.focus_point = focus_point
103106
self.color = color
@@ -150,8 +153,8 @@ def __init__(
150153
mobject: Mobject,
151154
scale_factor: float = 1.2,
152155
color: str = YELLOW,
153-
rate_func: Callable[[float, Optional[float]], np.ndarray] = there_and_back,
154-
**kwargs
156+
rate_func: Callable[[float, float | None], np.ndarray] = there_and_back,
157+
**kwargs,
155158
) -> None:
156159
self.color = color
157160
self.scale_factor = scale_factor
@@ -217,15 +220,15 @@ def construct(self):
217220

218221
def __init__(
219222
self,
220-
point: Union[np.ndarray, Mobject],
223+
point: np.ndarray | Mobject,
221224
line_length: float = 0.2,
222225
num_lines: int = 12,
223226
flash_radius: float = 0.1,
224227
line_stroke_width: int = 3,
225228
color: str = YELLOW,
226229
time_width: float = 1,
227230
run_time: float = 1.0,
228-
**kwargs
231+
**kwargs,
229232
) -> None:
230233
if isinstance(point, Mobject):
231234
self.point = point.get_center()
@@ -255,7 +258,7 @@ def create_lines(self) -> VGroup:
255258
lines.set_stroke(width=self.line_stroke_width)
256259
return lines
257260

258-
def create_line_anims(self) -> Iterable["ShowPassingFlash"]:
261+
def create_line_anims(self) -> Iterable[ShowPassingFlash]:
259262
return [
260263
ShowPassingFlash(
261264
line,
@@ -301,11 +304,11 @@ def construct(self):
301304
302305
"""
303306

304-
def __init__(self, mobject: "VMobject", time_width: float = 0.1, **kwargs) -> None:
307+
def __init__(self, mobject: VMobject, time_width: float = 0.1, **kwargs) -> None:
305308
self.time_width = time_width
306309
super().__init__(mobject, remover=True, introducer=True, **kwargs)
307310

308-
def _get_bounds(self, alpha: float) -> Tuple[float]:
311+
def _get_bounds(self, alpha: float) -> tuple[float]:
309312
tw = self.time_width
310313
upper = interpolate(0, 1 + tw, alpha)
311314
lower = upper - tw
@@ -393,7 +396,7 @@ def __init__(
393396
time_width: float = 1,
394397
ripples: int = 1,
395398
run_time: float = 2,
396-
**kwargs
399+
**kwargs,
397400
) -> None:
398401
x_min = mobject.get_left()[0]
399402
x_max = mobject.get_right()[0]
@@ -459,7 +462,7 @@ def homotopy(
459462
y: float,
460463
z: float,
461464
t: float,
462-
) -> Tuple[float, float, float]:
465+
) -> tuple[float, float, float]:
463466
upper = interpolate(0, 1 + time_width, t)
464467
lower = upper - time_width
465468
relative_x = inverse_interpolate(x_min, x_max, x)
@@ -509,10 +512,10 @@ def __init__(
509512
scale_value: float = 1.1,
510513
rotation_angle: float = 0.01 * TAU,
511514
n_wiggles: int = 6,
512-
scale_about_point: Optional[np.ndarray] = None,
513-
rotate_about_point: Optional[np.ndarray] = None,
515+
scale_about_point: np.ndarray | None = None,
516+
rotate_about_point: np.ndarray | None = None,
514517
run_time: float = 2,
515-
**kwargs
518+
**kwargs,
516519
) -> None:
517520
self.scale_value = scale_value
518521
self.rotation_angle = rotation_angle
@@ -593,15 +596,15 @@ def construct(self):
593596
def __init__(
594597
self,
595598
mobject: Mobject,
596-
shape: Type = Rectangle,
599+
shape: type = Rectangle,
597600
fade_in=False,
598601
fade_out=False,
599602
time_width=0.3,
600603
buff: float = SMALL_BUFF,
601604
color: ParsableManimColor = YELLOW,
602605
run_time=1,
603606
stroke_width=DEFAULT_STROKE_WIDTH,
604-
**kwargs
607+
**kwargs,
605608
):
606609
if shape is Rectangle:
607610
frame = SurroundingRectangle(
@@ -683,7 +686,7 @@ def __init__(
683686
time_off: float = 0.5,
684687
blinks: int = 1,
685688
hide_at_end: bool = False,
686-
**kwargs
689+
**kwargs,
687690
):
688691
animations = [
689692
UpdateFromFunc(

manim/animation/rotation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
__all__ = ["Rotating", "Rotate"]
66

7-
from typing import TYPE_CHECKING, Callable, Sequence
7+
from collections.abc import Sequence
8+
from typing import TYPE_CHECKING, Callable
89

910
import numpy as np
1011

manim/animation/specialized.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
__all__ = ["Broadcast"]
44

5-
from typing import Any, Sequence
5+
from collections.abc import Sequence
6+
from typing import Any
67

78
from manim.animation.transform import Restore
89

manim/animation/transform.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828

2929
import inspect
3030
import types
31-
from typing import TYPE_CHECKING, Any, Callable, Iterable, Sequence
31+
from collections.abc import Iterable, Sequence
32+
from typing import TYPE_CHECKING, Any, Callable
3233

3334
import numpy as np
3435

manim/camera/camera.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
import itertools as it
99
import operator as op
1010
import pathlib
11+
from collections.abc import Iterable
1112
from functools import reduce
12-
from typing import Any, Callable, Iterable
13+
from typing import Any, Callable
1314

1415
import cairo
1516
import numpy as np

manim/mobject/graph.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
]
99

1010
import itertools as it
11+
from collections.abc import Hashable, Iterable
1112
from copy import copy
12-
from typing import TYPE_CHECKING, Any, Hashable, Iterable, Literal, Protocol, cast
13+
from typing import TYPE_CHECKING, Any, Literal, Protocol, cast
1314

1415
import networkx as nx
1516
import numpy as np

manim/mobject/graphing/coordinate_systems.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313

1414
import fractions as fr
1515
import numbers
16-
from typing import TYPE_CHECKING, Any, Callable, Iterable, Sequence, TypeVar, overload
16+
from collections.abc import Iterable, Sequence
17+
from typing import TYPE_CHECKING, Any, Callable, TypeVar, overload
1718

1819
import numpy as np
1920
from typing_extensions import Self

manim/mobject/graphing/functions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
__all__ = ["ParametricFunction", "FunctionGraph", "ImplicitFunction"]
66

77

8-
from typing import TYPE_CHECKING, Callable, Iterable, Sequence
8+
from collections.abc import Iterable, Sequence
9+
from typing import TYPE_CHECKING, Callable
910

1011
import numpy as np
1112
from isosurfaces import plot_isoline

manim/mobject/graphing/number_line.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
__all__ = ["NumberLine", "UnitInterval"]
88

99

10-
from typing import TYPE_CHECKING, Callable, Iterable, Sequence
10+
from collections.abc import Iterable, Sequence
11+
from typing import TYPE_CHECKING, Callable
1112

1213
if TYPE_CHECKING:
1314
from manim.mobject.geometry.tips import ArrowTip

manim/mobject/graphing/probability.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
__all__ = ["SampleSpace", "BarChart"]
66

77

8-
from typing import Iterable, MutableSequence, Sequence
8+
from collections.abc import Iterable, MutableSequence, Sequence
99

1010
import numpy as np
1111

manim/mobject/graphing/scale.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from __future__ import annotations
22

33
import math
4-
from typing import TYPE_CHECKING, Any, Iterable
4+
from collections.abc import Iterable
5+
from typing import TYPE_CHECKING, Any
56

67
import numpy as np
78

manim/mobject/matrix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def construct(self):
4040

4141

4242
import itertools as it
43-
from typing import Iterable, Sequence
43+
from collections.abc import Iterable, Sequence
4444

4545
import numpy as np
4646

manim/mobject/mobject.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
import sys
1515
import types
1616
import warnings
17+
from collections.abc import Iterable
1718
from functools import partialmethod, reduce
1819
from pathlib import Path
19-
from typing import TYPE_CHECKING, Callable, Iterable, Literal
20+
from typing import TYPE_CHECKING, Callable, Literal
2021

2122
import numpy as np
2223

manim/mobject/opengl/opengl_mobject.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
import itertools as it
66
import random
77
import sys
8+
from collections.abc import Iterable, Sequence
89
from functools import partialmethod, wraps
910
from math import ceil
10-
from typing import Iterable, Sequence
1111

1212
import moderngl
1313
import numpy as np

manim/mobject/opengl/opengl_surface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

3+
from collections.abc import Iterable
34
from pathlib import Path
4-
from typing import Iterable
55

66
import moderngl
77
import numpy as np

manim/mobject/opengl/opengl_vectorized_mobject.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
import itertools as it
44
import operator as op
5+
from collections.abc import Iterable, Sequence
56
from functools import reduce, wraps
6-
from typing import Callable, Iterable, Sequence
7+
from typing import Callable
78

89
import moderngl
910
import numpy as np

manim/mobject/svg/brace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
__all__ = ["Brace", "BraceLabel", "ArcBrace", "BraceText", "BraceBetweenPoints"]
66

7-
from typing import Sequence
7+
from collections.abc import Sequence
88

99
import numpy as np
1010
import svgelements as se

manim/mobject/table.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ def construct(self):
6565

6666

6767
import itertools as it
68-
from typing import Callable, Iterable, Sequence
68+
from collections.abc import Iterable, Sequence
69+
from typing import Callable
6970

7071
from manim.mobject.geometry.line import Line
7172
from manim.mobject.geometry.polygram import Polygon

manim/mobject/text/numbers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
__all__ = ["DecimalNumber", "Integer", "Variable"]
66

7-
from typing import Sequence
7+
from collections.abc import Sequence
88

99
import numpy as np
1010

manim/mobject/text/tex_mobject.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
import itertools as it
2727
import operator as op
2828
import re
29+
from collections.abc import Iterable
2930
from functools import reduce
3031
from textwrap import dedent
31-
from typing import Iterable
3232

3333
from manim import config, logger
3434
from manim.constants import *

0 commit comments

Comments
 (0)