A community-maintained Python framework for creating mathematical animations.
Update pre-commit hooks (#4920)
Benjamin Hackl9dded44f1907
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex be5393e49..a0289ca5c 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -14,14 +14,14 @@ repos:name: Validate pyproject.toml- repo: https://github.com/codespell-project/codespell- rev: v2.4.1+ rev: v2.4.3hooks:- id: codespellfiles: ^.*\.(py|md|rst)$args: ["-L", "medias,nam"]- repo: https://github.com/astral-sh/ruff-pre-commit- rev: v0.14.10+ rev: v0.16.2hooks:- id: ruffname: ruff lint@@ -31,7 +31,7 @@ repos:types: [python]- repo: https://github.com/pre-commit/mirrors-mypy- rev: v1.19.1+ rev: v2.3.0hooks:- id: mypyadditional_dependencies:diff --git a/example_scenes/basic.py b/example_scenes/basic.pyindex 6e8c866f4..a94d17bd0 100644--- a/example_scenes/basic.py+++ b/example_scenes/basic.py@@ -53,13 +53,15 @@ class OpeningManim(Scene):grid.prepare_for_nonlinear_transform()self.play(grid.animate.apply_function(- lambda p: p- + np.array(- [- np.sin(p[1]),- np.sin(p[0]),- 0,- ],+ lambda p: (+ p+ + np.array(+ [+ np.sin(p[1]),+ np.sin(p[0]),+ 0,+ ],+ )),),run_time=3,diff --git a/manim/_config/utils.py b/manim/_config/utils.pyindex 53db049b6..4e7b35d53 100644--- a/manim/_config/utils.py+++ b/manim/_config/utils.py@@ -1057,7 +1057,7 @@ class ManimConfig(MutableMapping):"""File format; "png", "gif", "mp4", "webm" or "mov"."""return self._d["format"]- @format.setter+ @format.setter # noqa: A003def format(self, val: str) -> None:self._set_from_list("format",diff --git a/manim/mobject/opengl/opengl_mobject.py b/manim/mobject/opengl/opengl_mobject.pyindex 25fdf8b46..8a8714bba 100644--- a/manim/mobject/opengl/opengl_mobject.py+++ b/manim/mobject/opengl/opengl_mobject.py@@ -1200,7 +1200,7 @@ class OpenGLMobject:# make the grid as close to quadratic as possible.# choosing cols first can results in cols>rows.# This is favored over rows>cols since in general- # the sceene is wider than high.+ # the scene is wider than high.if rows is None:rows = ceil(len(mobs) / cols)if cols is None:@@ -3099,7 +3099,7 @@ class _AnimationBuilder:# NOTE: using `Self` here should not be a problem, because it's equivalent to a `TypeVar` introduced in `__getattr__`.# For this reason, here it's still in scope and can be used (that's why pyright does not flag this as an error).# However, mypy currently does not seem to understand this: hence the `type: ignore` comment.- def update_target(*method_args: object, **method_kwargs: object) -> Self: # type: ignore[type-var, misc]+ def update_target(*method_args: object, **method_kwargs: object) -> Self: # type: ignore[type-var]if has_overridden_animation:self.overridden_animation = cast("Callable[..., Animation]", method._override_animatediff --git a/manim/renderer/shader.py b/manim/renderer/shader.pyindex 64f7a0093..e57964daa 100644--- a/manim/renderer/shader.py+++ b/manim/renderer/shader.py@@ -247,9 +247,9 @@ class Object3D:def remove_updater(self, update_function: MeshUpdater) -> Self:while update_function in self.time_based_updaters:- self.time_based_updaters.remove(update_function) # type: ignore[arg-type]+ self.time_based_updaters.remove(update_function)while update_function in self.non_time_updaters:- self.non_time_updaters.remove(update_function) # type: ignore[arg-type]+ self.non_time_updaters.remove(update_function)self.refresh_has_updater_status()return selfdiff --git a/manim/scene/section.py b/manim/scene/section.pyindex 99e62c382..5b3463ec8 100644--- a/manim/scene/section.py+++ b/manim/scene/section.py@@ -2,7 +2,7 @@from __future__ import annotations-from enum import Enum+from enum import StrEnumfrom pathlib import Pathfrom typing import Any@@ -11,7 +11,7 @@ from manim import get_video_metadata__all__ = ["Section", "DefaultSectionType"]-class DefaultSectionType(str, Enum):+class DefaultSectionType(StrEnum):"""The type of a section can be used for third party applications.A presentation system could for example use the types to created loops.diff --git a/manim/utils/deprecation.py b/manim/utils/deprecation.pyindex 112c62fa5..4a2f7b80d 100644--- a/manim/utils/deprecation.py+++ b/manim/utils/deprecation.py@@ -407,9 +407,11 @@ def deprecated_params(@deprecated_params(redirections=[- lambda buff=1: {"buff_x": buff[0], "buff_y": buff[1]}- if isinstance(buff, tuple)- else {"buff_x": buff, "buff_y": buff}+ lambda buff=1: (+ {"buff_x": buff[0], "buff_y": buff[1]}+ if isinstance(buff, tuple)+ else {"buff_x": buff, "buff_y": buff}+ )])def foo(**kwargs):diff --git a/manim/utils/file_ops.py b/manim/utils/file_ops.pyindex 1e00c186d..f94a07618 100644--- a/manim/utils/file_ops.py+++ b/manim/utils/file_ops.py@@ -195,9 +195,12 @@ def modify_atime(file_path: str) -> None:def open_file(file_path: Path, in_browser: bool = False) -> None:current_os = platform.system()if current_os == "Windows":- # The method os.startfile is only available in Windows,- # ignoring type error caused by this.- os.startfile(file_path if not in_browser else file_path.parent) # type: ignore[attr-defined]+ # os.startfile is only available on Windows, so use getattr to keep+ # static analysis platform-independent.+ startfile = getattr(os, "startfile", None)+ if startfile is None:+ raise OSError("os.startfile is unavailable on this Windows system")+ startfile(file_path if not in_browser else file_path.parent)else:if current_os == "Linux":commands = ["xdg-open"]diff --git a/tests/test_scene_rendering/simple_scenes.py b/tests/test_scene_rendering/simple_scenes.pyindex ec190bbf0..744f4097b 100644--- a/tests/test_scene_rendering/simple_scenes.py+++ b/tests/test_scene_rendering/simple_scenes.py@@ -1,6 +1,6 @@from __future__ import annotations-from enum import Enum+from enum import StrEnumfrom manim import *@@ -111,7 +111,7 @@ class InteractiveStaticScene(Scene):class SceneWithSections(Scene):def construct(self):# this would be defined in a third party application using the segmented video API- class PresentationSectionType(str, Enum):+ class PresentationSectionType(StrEnum):# start, end, wait for continuation by userNORMAL = "presentation.normal"# start, end, immediately continue to next section