Skip to content

Commit f27307c

Browse files
Merge branch 'main' into Issue3562PR
2 parents df6cb94 + 6b66878 commit f27307c

File tree

86 files changed

+1276
-1017
lines changed

Some content is hidden

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

86 files changed

+1276
-1017
lines changed

.github/codeql.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ query-filters:
1010
- exclude:
1111
id: py/missing-call-to-init
1212
- exclude:
13-
id: py/method-first-arg-is-not-self
13+
id: py/method-first-arg-is-not-self
14+
- exclude:
15+
id: py/cyclic-import
16+
- exclude:
17+
id: py/unsafe-cyclic-import
1418
paths:
1519
- manim
1620
paths-ignore:

.github/scripts/ci_build_cairo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
import sys
1515
import tarfile
1616
import tempfile
17-
import typing
1817
import urllib.request
18+
from collections.abc import Generator
1919
from contextlib import contextmanager
2020
from pathlib import Path
2121
from sys import stdout
@@ -67,7 +67,7 @@ def run_command(command, cwd=None, env=None):
6767

6868

6969
@contextmanager
70-
def gha_group(title: str) -> typing.Generator:
70+
def gha_group(title: str) -> Generator:
7171
if not is_ci():
7272
yield
7373
return

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ fail_fast: false
33
exclude: ^(manim/grpc/gen/|docs/i18n/)
44
repos:
55
- repo: https://github.com/pre-commit/pre-commit-hooks
6-
rev: v5.0.0
6+
rev: v6.0.0
77
hooks:
88
- id: check-ast
99
name: Validate Python
@@ -13,7 +13,7 @@ repos:
1313
- id: check-toml
1414
name: Validate pyproject.toml
1515
- repo: https://github.com/astral-sh/ruff-pre-commit
16-
rev: v0.11.0
16+
rev: v0.12.8
1717
hooks:
1818
- id: ruff
1919
name: ruff lint
@@ -22,7 +22,7 @@ repos:
2222
- id: ruff-format
2323
types: [python]
2424
- repo: https://github.com/pre-commit/mirrors-mypy
25-
rev: v1.15.0
25+
rev: v1.17.1
2626
hooks:
2727
- id: mypy
2828
additional_dependencies:

docs/source/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
# This specifies any additional css files that will override the theme's
157157
html_css_files = ["custom.css"]
158158

159+
latex_engine = "lualatex"
159160

160161
# external links
161162
extlinks = {

manim/_config/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,14 @@ def make_config_parser(
122122
# read_file() before calling read() for any optional files."
123123
# https://docs.python.org/3/library/configparser.html#configparser.ConfigParser.read
124124
parser = configparser.ConfigParser()
125+
logger.info(f"Reading config file: {library_wide}")
125126
with library_wide.open() as file:
126127
parser.read_file(file) # necessary file
127128

128129
other_files = [user_wide, Path(custom_file) if custom_file else folder_wide]
130+
for path in other_files:
131+
if path.exists():
132+
logger.info(f"Reading config file: {path}")
129133
parser.read(other_files) # optional files
130134

131135
return parser
@@ -1414,7 +1418,7 @@ def window_position(self, value: str) -> None:
14141418

14151419
@property
14161420
def window_size(self) -> str:
1417-
"""The size of the opengl window. 'default' to automatically scale the window based on the display monitor."""
1421+
"""The size of the opengl window as 'width,height' or 'default' to automatically scale the window based on the display monitor."""
14181422
return self._d["window_size"]
14191423

14201424
@window_size.setter

manim/animation/animation.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
__all__ = ["Animation", "Wait", "Add", "override_animation"]
1515

1616

17-
from collections.abc import Iterable, Sequence
17+
from collections.abc import Callable, Iterable, Sequence
1818
from copy import deepcopy
1919
from functools import partialmethod
20-
from typing import TYPE_CHECKING, Any, Callable
20+
from typing import TYPE_CHECKING, Any
2121

2222
from typing_extensions import Self
2323

@@ -129,7 +129,7 @@ def __new__(
129129

130130
def __init__(
131131
self,
132-
mobject: Mobject | None,
132+
mobject: Mobject | OpenGLMobject | None,
133133
lag_ratio: float = DEFAULT_ANIMATION_LAG_RATIO,
134134
run_time: float = DEFAULT_ANIMATION_RUN_TIME,
135135
rate_func: Callable[[float], float] = smooth,
@@ -262,11 +262,11 @@ def _setup_scene(self, scene: Scene) -> None:
262262
):
263263
scene.add(self.mobject)
264264

265-
def create_starting_mobject(self) -> Mobject:
265+
def create_starting_mobject(self) -> Mobject | OpenGLMobject:
266266
# Keep track of where the mobject starts
267267
return self.mobject.copy()
268268

269-
def get_all_mobjects(self) -> Sequence[Mobject]:
269+
def get_all_mobjects(self) -> Sequence[Mobject | OpenGLMobject]:
270270
"""Get all mobjects involved in the animation.
271271
272272
Ordering must match the ordering of arguments to interpolate_submobject

manim/animation/changing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
__all__ = ["AnimatedBoundary", "TracedPath"]
66

7-
from collections.abc import Sequence
8-
from typing import Callable
7+
from collections.abc import Callable, Sequence
8+
from typing import Any
99

10-
from typing_extensions import Any, Self
10+
from typing_extensions import Self
1111

1212
from manim.mobject.mobject import Mobject
1313
from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL

manim/animation/composition.py

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22

33
from __future__ import annotations
44

5-
import types
6-
from collections.abc import Iterable, Sequence
7-
from typing import TYPE_CHECKING, Callable
5+
from collections.abc import Callable, Iterable, Sequence
6+
from typing import TYPE_CHECKING, Any
87

98
import numpy as np
109

1110
from manim._config import config
1211
from manim.animation.animation import Animation, prepare_animation
1312
from manim.constants import RendererType
1413
from manim.mobject.mobject import Group, Mobject
15-
from manim.mobject.opengl.opengl_mobject import OpenGLGroup
14+
from manim.mobject.opengl.opengl_mobject import OpenGLGroup, OpenGLMobject
1615
from manim.scene.scene import Scene
1716
from manim.utils.iterables import remove_list_redundancies
1817
from manim.utils.parameter_parsing import flatten_iterable_parameters
@@ -54,31 +53,34 @@ class AnimationGroup(Animation):
5453

5554
def __init__(
5655
self,
57-
*animations: Animation | Iterable[Animation] | types.GeneratorType[Animation],
58-
group: Group | VGroup | OpenGLGroup | OpenGLVGroup = None,
56+
*animations: Animation | Iterable[Animation],
57+
group: Group | VGroup | OpenGLGroup | OpenGLVGroup | None = None,
5958
run_time: float | None = None,
6059
rate_func: Callable[[float], float] = linear,
6160
lag_ratio: float = 0,
62-
**kwargs,
63-
) -> None:
61+
**kwargs: Any,
62+
):
6463
arg_anim = flatten_iterable_parameters(animations)
6564
self.animations = [prepare_animation(anim) for anim in arg_anim]
6665
self.rate_func = rate_func
67-
self.group = group
68-
if self.group is None:
66+
if group is None:
6967
mobjects = remove_list_redundancies(
7068
[anim.mobject for anim in self.animations if not anim.is_introducer()],
7169
)
7270
if config["renderer"] == RendererType.OPENGL:
73-
self.group = OpenGLGroup(*mobjects)
71+
self.group: Group | VGroup | OpenGLGroup | OpenGLVGroup = OpenGLGroup(
72+
*mobjects
73+
)
7474
else:
7575
self.group = Group(*mobjects)
76+
else:
77+
self.group = group
7678
super().__init__(
7779
self.group, rate_func=self.rate_func, lag_ratio=lag_ratio, **kwargs
7880
)
7981
self.run_time: float = self.init_run_time(run_time)
8082

81-
def get_all_mobjects(self) -> Sequence[Mobject]:
83+
def get_all_mobjects(self) -> Sequence[Mobject | OpenGLMobject]:
8284
return list(self.group)
8385

8486
def begin(self) -> None:
@@ -93,7 +95,7 @@ def begin(self) -> None:
9395
for anim in self.animations:
9496
anim.begin()
9597

96-
def _setup_scene(self, scene) -> None:
98+
def _setup_scene(self, scene: Scene) -> None:
9799
for anim in self.animations:
98100
anim._setup_scene(scene)
99101

@@ -118,7 +120,7 @@ def update_mobjects(self, dt: float) -> None:
118120
]:
119121
anim.update_mobjects(dt)
120122

121-
def init_run_time(self, run_time) -> float:
123+
def init_run_time(self, run_time: float | None) -> float:
122124
"""Calculates the run time of the animation, if different from ``run_time``.
123125
124126
Parameters
@@ -146,9 +148,9 @@ def build_animations_with_timings(self) -> None:
146148
run_times = np.array([anim.run_time for anim in self.animations])
147149
num_animations = run_times.shape[0]
148150
dtype = [("anim", "O"), ("start", "f8"), ("end", "f8")]
149-
self.anims_with_timings = np.zeros(num_animations, dtype=dtype)
150-
self.anims_begun = np.zeros(num_animations, dtype=bool)
151-
self.anims_finished = np.zeros(num_animations, dtype=bool)
151+
self.anims_with_timings: np.ndarray = np.zeros(num_animations, dtype=dtype)
152+
self.anims_begun: np.ndarray = np.zeros(num_animations, dtype=bool)
153+
self.anims_finished: np.ndarray = np.zeros(num_animations, dtype=bool)
152154
if num_animations == 0:
153155
return
154156

@@ -228,7 +230,7 @@ def construct(self):
228230
))
229231
"""
230232

231-
def __init__(self, *animations: Animation, lag_ratio: float = 1, **kwargs) -> None:
233+
def __init__(self, *animations: Animation, lag_ratio: float = 1, **kwargs: Any):
232234
super().__init__(*animations, lag_ratio=lag_ratio, **kwargs)
233235

234236
def begin(self) -> None:
@@ -247,7 +249,7 @@ def update_mobjects(self, dt: float) -> None:
247249
if self.active_animation:
248250
self.active_animation.update_mobjects(dt)
249251

250-
def _setup_scene(self, scene) -> None:
252+
def _setup_scene(self, scene: Scene | None) -> None:
251253
if scene is None:
252254
return
253255
if self.is_introducer():
@@ -339,7 +341,7 @@ def __init__(
339341
self,
340342
*animations: Animation,
341343
lag_ratio: float = DEFAULT_LAGGED_START_LAG_RATIO,
342-
**kwargs,
344+
**kwargs: Any,
343345
):
344346
super().__init__(*animations, lag_ratio=lag_ratio, **kwargs)
345347

@@ -384,20 +386,22 @@ def construct(self):
384386

385387
def __init__(
386388
self,
387-
AnimationClass: Callable[..., Animation],
389+
animation_class: type[Animation],
388390
mobject: Mobject,
389-
arg_creator: Callable[[Mobject], str] = None,
391+
arg_creator: Callable[[Mobject], Iterable[Any]] | None = None,
390392
run_time: float = 2,
391-
**kwargs,
392-
) -> None:
393-
args_list = []
394-
for submob in mobject:
395-
if arg_creator:
396-
args_list.append(arg_creator(submob))
397-
else:
398-
args_list.append((submob,))
393+
**kwargs: Any,
394+
):
395+
if arg_creator is None:
396+
397+
def identity(mob: Mobject) -> Mobject:
398+
return mob
399+
400+
arg_creator = identity
401+
402+
args_list = [arg_creator(submob) for submob in mobject]
399403
anim_kwargs = dict(kwargs)
400404
if "lag_ratio" in anim_kwargs:
401405
anim_kwargs.pop("lag_ratio")
402-
animations = [AnimationClass(*args, **anim_kwargs) for args in args_list]
406+
animations = [animation_class(*args, **anim_kwargs) for args in args_list]
403407
super().__init__(*animations, run_time=run_time, **kwargs)

manim/animation/creation.py

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

7777

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

8282
import numpy as np
8383

manim/animation/fading.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ def construct(self):
1919
"FadeIn",
2020
]
2121

22+
from typing import Any
23+
2224
import numpy as np
23-
from typing_extensions import Any
2425

2526
from manim.mobject.opengl.opengl_mobject import OpenGLMobject
2627

0 commit comments

Comments
 (0)