Skip to content

Commit

Permalink
Use Ruff pygrep rules (#3923)
Browse files Browse the repository at this point in the history
* Add config for ruff pygrep

* Fix pygrep linting errors
  • Loading branch information
JasonGrace2282 authored Sep 1, 2024
1 parent 2536b7f commit 74f79a4
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 21 deletions.
5 changes: 0 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion example_scenes/opengl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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.
Expand Down
2 changes: 1 addition & 1 deletion manim/cli/render/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
@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,
Expand Down
2 changes: 1 addition & 1 deletion manim/cli/render/render_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def validate_resolution(ctx, param, value):
"--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: "
Expand Down
6 changes: 3 additions & 3 deletions manim/utils/bezier.py
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ def match_interpolate(
return interpolate(
new_start,
new_end,
old_alpha, # type: ignore
old_alpha, # type: ignore[arg-type]
)


Expand Down Expand Up @@ -1900,15 +1900,15 @@ 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)

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

Expand Down
8 changes: 4 additions & 4 deletions manim/utils/color/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,21 +163,21 @@ def __init__(
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}"
)
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}"
Expand Down
2 changes: 1 addition & 1 deletion manim/utils/docbuild/manim_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def construct(self):

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
Expand Down
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ select = [
"E",
"F",
"I",
"PGH",
"PT",
"SIM",
"UP",
Expand Down Expand Up @@ -202,7 +203,3 @@ convention = "numpy"

[tool.ruff.format]
docstring-code-format = true

[tool.codespell]
write-changes = true
ignore-words-list = ["medias", "nam"]
2 changes: 1 addition & 1 deletion tests/test_scene_rendering/opengl/test_opengl_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 74f79a4

Please sign in to comment.