Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Use Ruff pygrep rules (#3923)

Aarush Deshpande74f79a42b67b
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index aeabc54ac..a4c90fccb 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -12,11 +12,6 @@ repos:
- id: end-of-file-fixer
- id: check-toml
name: Validate Poetry
- - repo: https://github.com/pre-commit/pygrep-hooks
- rev: v1.10.0
- hooks:
- - id: python-check-blanket-noqa
- name: Precision flake ignores
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.2
hooks:
diff --git a/example_scenes/opengl.py b/example_scenes/opengl.py
index 27f579a6e..baa59899c 100644
--- a/example_scenes/opengl.py
+++ b/example_scenes/opengl.py
@@ -2,7 +2,7 @@ from pathlib import Path
import manim.utils.opengl as opengl
from manim import *
-from manim.opengl import * # type: ignore
+from manim.opengl import *
# Copied from https://3b1b.github.io/manim/getting_started/example_scenes.html#surfaceexample.
# Lines that do not yet work with the Community Version are commented.
diff --git a/manim/cli/render/commands.py b/manim/cli/render/commands.py
index b5659766a..4a1810a11 100644
--- a/manim/cli/render/commands.py
+++ b/manim/cli/render/commands.py
@@ -39,7 +39,7 @@ __all__ = ["render"]
@cloup.argument("scene_names", required=False, nargs=-1)
@global_options
@output_options
-@render_options # type: ignore
+@render_options
@ease_of_access_options
def render(
**args,
diff --git a/manim/cli/render/render_options.py b/manim/cli/render/render_options.py
index 21a91ce39..fabcb8d87 100644
--- a/manim/cli/render/render_options.py
+++ b/manim/cli/render/render_options.py
@@ -72,7 +72,7 @@ render_options = option_group(
"--quality",
default=None,
type=Choice(
- list(reversed([q["flag"] for q in QUALITIES.values() if q["flag"]])), # type: ignore
+ reversed([q["flag"] for q in QUALITIES.values() if q["flag"]]), # type: ignore[arg-type]
case_sensitive=False,
),
help="Render quality at the follow resolution framerates, respectively: "
diff --git a/manim/utils/bezier.py b/manim/utils/bezier.py
index e45c0bf5d..b12e6e52c 100644
--- a/manim/utils/bezier.py
+++ b/manim/utils/bezier.py
@@ -1113,7 +1113,7 @@ def match_interpolate(
return interpolate(
new_start,
new_end,
- old_alpha, # type: ignore
+ old_alpha, # type: ignore[arg-type]
)
@@ -1900,7 +1900,7 @@ def proportions_along_bezier_curve_for_point(
# Roots will be none, but in this specific instance, we don't need to consider that.
continue
bezier_polynom = np.polynomial.Polynomial(terms[::-1])
- polynom_roots = bezier_polynom.roots() # type: ignore
+ polynom_roots = bezier_polynom.roots()
if len(polynom_roots) > 0:
polynom_roots = np.around(polynom_roots, int(np.log10(1 / round_to)))
roots.append(polynom_roots)
@@ -1908,7 +1908,7 @@ def proportions_along_bezier_curve_for_point(
roots = [[root for root in rootlist if root.imag == 0] for rootlist in roots]
# Get common roots
# arg-type: ignore
- roots = reduce(np.intersect1d, roots) # type: ignore
+ roots = reduce(np.intersect1d, roots)
result = np.asarray([r.real for r in roots if 0 <= r.real <= 1])
return result
diff --git a/manim/utils/color/core.py b/manim/utils/color/core.py
index 4c012c140..63c1605dc 100644
--- a/manim/utils/color/core.py
+++ b/manim/utils/color/core.py
@@ -163,9 +163,9 @@ class ManimColor:
length = len(value)
if all(isinstance(x, float) for x in value):
if length == 3:
- self._internal_value = ManimColor._internal_from_rgb(value, alpha) # type: ignore
+ self._internal_value = ManimColor._internal_from_rgb(value, alpha) # type: ignore[arg-type]
elif length == 4:
- self._internal_value = ManimColor._internal_from_rgba(value) # type: ignore
+ self._internal_value = ManimColor._internal_from_rgba(value) # type: ignore[arg-type]
else:
raise ValueError(
f"ManimColor only accepts lists/tuples/arrays of length 3 or 4, not {length}"
@@ -173,11 +173,11 @@ class ManimColor:
else:
if length == 3:
self._internal_value = ManimColor._internal_from_int_rgb(
- value, # type: ignore
+ value, # type: ignore[arg-type]
alpha,
)
elif length == 4:
- self._internal_value = ManimColor._internal_from_int_rgba(value) # type: ignore
+ self._internal_value = ManimColor._internal_from_int_rgba(value) # type: ignore[arg-type]
else:
raise ValueError(
f"ManimColor only accepts lists/tuples/arrays of length 3 or 4, not {length}"
diff --git a/manim/utils/docbuild/manim_directive.py b/manim/utils/docbuild/manim_directive.py
index 7ca7d6864..4576be81d 100644
--- a/manim/utils/docbuild/manim_directive.py
+++ b/manim/utils/docbuild/manim_directive.py
@@ -92,7 +92,7 @@ from typing import TYPE_CHECKING, Any
import jinja2
from docutils import nodes
-from docutils.parsers.rst import Directive, directives # type: ignore
+from docutils.parsers.rst import Directive, directives
from docutils.statemachine import StringList
from manim import QUALITIES
diff --git a/pyproject.toml b/pyproject.toml
index b7f297330..1419d1c68 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -133,6 +133,7 @@ select = [
"E",
"F",
"I",
+ "PGH",
"PT",
"SIM",
"UP",
@@ -202,7 +203,3 @@ convention = "numpy"
[tool.ruff.format]
docstring-code-format = true
-
-[tool.codespell]
-write-changes = true
-ignore-words-list = ["medias", "nam"]
diff --git a/tests/test_scene_rendering/opengl/test_opengl_renderer.py b/tests/test_scene_rendering/opengl/test_opengl_renderer.py
index 71454d225..f2236cb04 100644
--- a/tests/test_scene_rendering/opengl/test_opengl_renderer.py
+++ b/tests/test_scene_rendering/opengl/test_opengl_renderer.py
@@ -23,7 +23,7 @@ def test_write_to_movie_disables_window(
assert_file_exists(config.output_file)
[email protected](reason="Temporarily skip due to failing in Windows CI") # type: ignore
[email protected](reason="Temporarily skip due to failing in Windows CI")
def test_force_window_opengl_render_with_movies(
config,
using_temp_opengl_config,