Use Ruff pygrep rules (#3923)

* Add config for ruff pygrep

* Fix pygrep linting errors
This commit is contained in:
Aarush Deshpande 2024-09-01 11:55:22 -04:00 committed by GitHub
commit 74f79a42b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 13 additions and 21 deletions

View file

@ -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:

View file

@ -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.

View file

@ -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,

View file

@ -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: "

View file

@ -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

View file

@ -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}"

View file

@ -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

View file

@ -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"]

View file

@ -23,7 +23,7 @@ def test_write_to_movie_disables_window(
assert_file_exists(config.output_file)
@pytest.mark.skip(reason="Temporarily skip due to failing in Windows CI") # type: ignore
@pytest.mark.skip(reason="Temporarily skip due to failing in Windows CI")
def test_force_window_opengl_render_with_movies(
config,
using_temp_opengl_config,