From 943618e877de708bc49833b62541df6f53c62ef9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 4 Aug 2025 17:13:23 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.11.0 → v0.12.7](https://github.com/astral-sh/ruff-pre-commit/compare/v0.11.0...v0.12.7) - [github.com/pre-commit/mirrors-mypy: v1.15.0 → v1.17.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.15.0...v1.17.1) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fdc48e8371..81dcc7cf24 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: From 45bb9e5a1874e7521951986ea9d30b8a7376b118 Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Sat, 9 Aug 2025 11:14:02 -0400 Subject: [PATCH 2/2] Fix errors --- manim/mobject/graphing/functions.py | 2 +- manim/mobject/graphing/probability.py | 2 +- manim/mobject/mobject.py | 5 +---- manim/mobject/opengl/opengl_mobject.py | 5 +---- manim/mobject/svg/svg_mobject.py | 6 +++--- manim/scene/vector_space_scene.py | 2 +- manim/utils/deprecation.py | 2 +- manim/utils/docbuild/manim_directive.py | 4 ++-- manim/utils/docbuild/module_parsing.py | 4 ++-- manim/utils/ipython_magic.py | 2 +- 10 files changed, 14 insertions(+), 20 deletions(-) diff --git a/manim/mobject/graphing/functions.py b/manim/mobject/graphing/functions.py index d125f45b6b..22313b2827 100644 --- a/manim/mobject/graphing/functions.py +++ b/manim/mobject/graphing/functions.py @@ -228,7 +228,7 @@ def __init__( 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 309e0b7ec2..9b88179bdc 100644 --- a/manim/mobject/graphing/probability.py +++ b/manim/mobject/graphing/probability.py @@ -172,7 +172,7 @@ def get_subdivision_braces_and_labels( "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 fc818fd603..2fe7d7cb0e 100644 --- a/manim/mobject/mobject.py +++ b/manim/mobject/mobject.py @@ -3288,10 +3288,7 @@ def build(self) -> Animation: _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 d0a3306f7f..0b08123e88 100644 --- a/manim/mobject/opengl/opengl_mobject.py +++ b/manim/mobject/opengl/opengl_mobject.py @@ -2993,10 +2993,7 @@ def update_target(*method_args, **method_kwargs): 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 6e4cc6f6c3..84f278efe6 100644 --- a/manim/mobject/svg/svg_mobject.py +++ b/manim/mobject/svg/svg_mobject.py @@ -195,7 +195,7 @@ def generate_mobject(self) -> None: """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 @@ def modify_xml_tree(self, element_tree: ET.ElementTree) -> ET.ElementTree: "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 d20a6901e7..3ceab6a9bf 100644 --- a/manim/scene/vector_space_scene.py +++ b/manim/scene/vector_space_scene.py @@ -973,7 +973,7 @@ def add_transformable_label( ) 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 d8bb9fb97c..877f745079 100644 --- a/manim/utils/deprecation.py +++ b/manim/utils/deprecation.py @@ -253,7 +253,7 @@ def deprecate(func: Callable[..., T], *args: Any, **kwargs: Any) -> T: # The following line raises this mypy error: # Accessing "__init__" on an instance is unsound, since instance.__init__ # could be from an incompatible subclass [misc] - 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 b94b7386c9..f1c3d75f17 100644 --- a/manim/utils/docbuild/manim_directive.py +++ b/manim/utils/docbuild/manim_directive.py @@ -268,11 +268,11 @@ def run(self) -> list[nodes.Element]: ] 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 78769eb565..6e5a6bb2bf 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 ce6c93d552..1d62bbc6f4 100644 --- a/manim/utils/ipython_magic.py +++ b/manim/utils/ipython_magic.py @@ -129,7 +129,7 @@ def construct(self): 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: