Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

[pre-commit.ci] pre-commit autoupdate (#4204)

pre-commit-ci[bot]2d8d81c209d6
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index fdc48e837..81dcc7cf2 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -13,7 +13,7 @@ repos:
- id: check-toml
name: Validate pyproject.toml
- repo: https://github.com/astral-sh/ruff-pre-commit
- rev: v0.11.0
+ rev: v0.12.7
hooks:
- id: ruff
name: ruff lint
@@ -22,7 +22,7 @@ repos:
- id: ruff-format
types: [python]
- repo: https://github.com/pre-commit/mirrors-mypy
- rev: v1.15.0
+ rev: v1.17.1
hooks:
- id: mypy
additional_dependencies:
diff --git a/manim/mobject/graphing/functions.py b/manim/mobject/graphing/functions.py
index d125f45b6..22313b282 100644
--- a/manim/mobject/graphing/functions.py
+++ b/manim/mobject/graphing/functions.py
@@ -228,7 +228,7 @@ class FunctionGraph(ParametricFunction):
self.parametric_function: Callable[[float], Point3D] = lambda t: np.array(
[t, function(t), 0]
)
- self.function: Callable[[float], Any] = function
+ self.function = function # type: ignore[assignment]
super().__init__(self.parametric_function, self.x_range, color=color, **kwargs)
def get_function(self) -> Callable[[float], Any]:
diff --git a/manim/mobject/graphing/probability.py b/manim/mobject/graphing/probability.py
index 309e0b7ec..9b88179bd 100644
--- a/manim/mobject/graphing/probability.py
+++ b/manim/mobject/graphing/probability.py
@@ -172,7 +172,7 @@ class SampleSpace(Rectangle):
"direction": direction,
"buff": buff,
}
- return VGroup(parts.braces, parts.labels)
+ return VGroup(parts.braces, parts.labels) # type: ignore[arg-type]
def get_side_braces_and_labels(
self,
diff --git a/manim/mobject/mobject.py b/manim/mobject/mobject.py
index fc818fd60..2fe7d7cb0 100644
--- a/manim/mobject/mobject.py
+++ b/manim/mobject/mobject.py
@@ -3288,10 +3288,7 @@ class _AnimationBuilder:
_MethodAnimation,
)
- if self.overridden_animation:
- anim = self.overridden_animation
- else:
- anim = _MethodAnimation(self.mobject, self.methods)
+ anim = self.overridden_animation or _MethodAnimation(self.mobject, self.methods)
for attr, value in self.anim_args.items():
setattr(anim, attr, value)
diff --git a/manim/mobject/opengl/opengl_mobject.py b/manim/mobject/opengl/opengl_mobject.py
index d0a3306f7..0b08123e8 100644
--- a/manim/mobject/opengl/opengl_mobject.py
+++ b/manim/mobject/opengl/opengl_mobject.py
@@ -2993,10 +2993,7 @@ class _AnimationBuilder:
def build(self) -> _MethodAnimation:
from manim.animation.transform import _MethodAnimation
- if self.overridden_animation:
- anim = self.overridden_animation
- else:
- anim = _MethodAnimation(self.mobject, self.methods)
+ anim = self.overridden_animation or _MethodAnimation(self.mobject, self.methods)
for attr, value in self.anim_args.items():
setattr(anim, attr, value)
diff --git a/manim/mobject/svg/svg_mobject.py b/manim/mobject/svg/svg_mobject.py
index 6e4cc6f6c..84f278efe 100644
--- a/manim/mobject/svg/svg_mobject.py
+++ b/manim/mobject/svg/svg_mobject.py
@@ -195,7 +195,7 @@ class SVGMobject(VMobject, metaclass=ConvertToOpenGL):
"""Parse the SVG and translate its elements to submobjects."""
file_path = self.get_file_path()
element_tree = ET.parse(file_path)
- new_tree = self.modify_xml_tree(element_tree)
+ new_tree = self.modify_xml_tree(element_tree) # type: ignore[arg-type]
# Create a temporary svg file to dump modified svg to be parsed
modified_file_path = file_path.with_name(f"{file_path.stem}_{file_path.suffix}")
new_tree.write(modified_file_path)
@@ -232,12 +232,12 @@ class SVGMobject(VMobject, metaclass=ConvertToOpenGL):
"style",
)
root = element_tree.getroot()
- root_style_dict = {k: v for k, v in root.attrib.items() if k in style_keys}
+ root_style_dict = {k: v for k, v in root.attrib.items() if k in style_keys} # type: ignore[union-attr]
new_root = ET.Element("svg", {})
config_style_node = ET.SubElement(new_root, "g", config_style_dict)
root_style_node = ET.SubElement(config_style_node, "g", root_style_dict)
- root_style_node.extend(root)
+ root_style_node.extend(root) # type: ignore[arg-type]
return ET.ElementTree(new_root)
def generate_config_style_dict(self) -> dict[str, str]:
diff --git a/manim/scene/vector_space_scene.py b/manim/scene/vector_space_scene.py
index d20a6901e..3ceab6a9b 100644
--- a/manim/scene/vector_space_scene.py
+++ b/manim/scene/vector_space_scene.py
@@ -973,7 +973,7 @@ class LinearTransformationScene(VectorScene):
)
label_mob.vector = vector # type: ignore[attr-defined]
label_mob.kwargs = kwargs # type: ignore[attr-defined]
- if "animate" in label_mob.kwargs: # type: ignore[attr-defined]
+ if "animate" in label_mob.kwargs: # type: ignore[operator]
label_mob.kwargs.pop("animate") # type: ignore[attr-defined]
self.transformable_labels.append(label_mob)
return cast(MathTex, label_mob)
diff --git a/manim/utils/deprecation.py b/manim/utils/deprecation.py
index d8bb9fb97..877f74507 100644
--- a/manim/utils/deprecation.py
+++ b/manim/utils/deprecation.py
@@ -253,7 +253,7 @@ def deprecated(
# The following line raises this mypy error:
# Accessing "__init__" on an instance is unsound, since instance.__init__
# could be from an incompatible subclass [misc]</pre>
- func.__init__ = decorate(func.__init__, deprecate) # type: ignore[misc]
+ func.__init__ = decorate(func.__init__, deprecate) # type: ignore[method-assign]
return func
func = decorate(func, deprecate)
diff --git a/manim/utils/docbuild/manim_directive.py b/manim/utils/docbuild/manim_directive.py
index d2e8c74ae..bf4fb554c 100644
--- a/manim/utils/docbuild/manim_directive.py
+++ b/manim/utils/docbuild/manim_directive.py
@@ -268,11 +268,11 @@ class ManimDirective(Directive):
]
source_block = "\n".join(source_block_in)
- config.media_dir = (Path(setup.confdir) / "media").absolute() # type: ignore[attr-defined,assignment]
+ config.media_dir = (Path(setup.confdir) / "media").absolute() # type: ignore[attr-defined]
config.images_dir = "{media_dir}/images"
config.video_dir = "{media_dir}/videos/{quality}"
output_file = f"{clsname}-{classnamedict[clsname]}"
- config.assets_dir = Path("_static") # type: ignore[assignment]
+ config.assets_dir = Path("_static")
config.progress_bar = "none"
config.verbosity = "WARNING"
diff --git a/manim/utils/docbuild/module_parsing.py b/manim/utils/docbuild/module_parsing.py
index 78769eb56..6e5a6bb2b 100644
--- a/manim/utils/docbuild/module_parsing.py
+++ b/manim/utils/docbuild/module_parsing.py
@@ -177,8 +177,8 @@ def parse_module_attributes() -> tuple[AliasDocsDict, DataDict, TypeVarDict]:
# TODO: ast.TypeAlias does not exist before Python 3.12, and that
# could be the reason why MyPy does not recognize these as
# attributes of node.
- alias_name = node.name.id if is_type_alias else node.target.id # type: ignore[attr-defined]
- definition_node = node.value # type: ignore[attr-defined]
+ alias_name = node.name.id if is_type_alias else node.target.id
+ definition_node = node.value
# If the definition is a Union, replace with vertical bar notation.
# Instead of "Union[Type1, Type2]", we'll have "Type1 | Type2".
diff --git a/manim/utils/ipython_magic.py b/manim/utils/ipython_magic.py
index ce6c93d55..1d62bbc6f 100644
--- a/manim/utils/ipython_magic.py
+++ b/manim/utils/ipython_magic.py
@@ -129,7 +129,7 @@ else:
args = main(modified_args, standalone_mode=False, prog_name="manim")
assert isinstance(local_ns, dict)
with tempconfig(local_ns.get("config", {})):
- config.digest_args(args) # type: ignore[arg-type]
+ config.digest_args(args)
renderer = None
if config.renderer == RendererType.OPENGL: