From 3dbf7af4969fba49913a53cfd977a15a5d089c2e Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Wed, 22 May 2024 12:07:29 -0400 Subject: [PATCH 01/16] add linting --- .pre-commit-config.yaml | 15 +++-------- example_scenes/advanced_tex_fonts.py | 2 ++ example_scenes/basic.py | 2 +- example_scenes/customtex.py | 2 ++ example_scenes/opengl.py | 2 ++ manim/animation/indication.py | 1 - manim/cli/checkhealth/checks.py | 3 --- manim/cli/default_group.py | 2 ++ manim/mobject/graph.py | 2 +- manim/mobject/opengl/opengl_surface.py | 1 - manim/mobject/text/code_mobject.py | 1 - manim/mobject/text/text_mobject.py | 1 - manim/mobject/three_d/three_dimensions.py | 6 ----- manim/renderer/opengl_renderer.py | 1 - manim/scene/scene.py | 2 +- manim/utils/bezier.py | 2 -- manim/utils/color/AS2700.py | 2 ++ manim/utils/color/BS381.py | 2 ++ manim/utils/color/X11.py | 2 ++ manim/utils/color/XKCD.py | 2 ++ manim/utils/color/__init__.py | 2 ++ manim/utils/color/manim_colors.py | 2 +- .../utils/docbuild/autoaliasattr_directive.py | 1 - manim/utils/docbuild/manim_directive.py | 1 - manim/utils/ipython_magic.py | 3 +-- manim/utils/module_ops.py | 1 - manim/utils/simple_functions.py | 2 -- manim/utils/space_ops.py | 2 +- pyproject.toml | 25 +++++++++++++++++++ scripts/extract_frames.py | 2 ++ tests/interface/test_commands.py | 2 +- .../graphing/test_coordinate_system.py | 16 ++++++++++-- tests/module/mobject/test_image.py | 2 ++ tests/module/mobject/text/test_texmobject.py | 2 -- .../test_vectorized_mobject.py | 2 ++ tests/module/scene/test_threed_scene.py | 2 ++ tests/module/utils/_split_matrices.py | 2 ++ tests/module/utils/_subdivision_matrices.py | 2 ++ tests/module/utils/test_space_ops.py | 2 +- tests/module/utils/test_tex.py | 2 ++ tests/opengl/test_coordinate_system_opengl.py | 16 ++++++++++-- tests/opengl/test_opengl_surface.py | 2 ++ tests/test_code_mobject.py | 2 ++ tests/test_config.py | 1 - .../test_graphical_units/test_probability.py | 2 ++ .../test_graphical_units/test_tex_mobject.py | 2 +- tests/test_graphical_units/test_text.py | 4 +-- tests/test_linear_transformation_scene.py | 2 ++ tests/test_logging/bad_tex_scene.py | 2 ++ .../test_scene_rendering/test_file_writer.py | 2 ++ 50 files changed, 112 insertions(+), 51 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index de2a017cfc..b8d8e7b9d3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,17 +12,6 @@ repos: - id: end-of-file-fixer - id: check-toml name: Validate Poetry - - repo: https://github.com/pycqa/isort - rev: 5.13.2 - hooks: - - id: isort - name: isort (python) - - id: isort - name: isort (cython) - types: [cython] - - id: isort - name: isort (pyi) - types: [pyi] - repo: https://github.com/asottile/pyupgrade rev: v3.15.2 hooks: @@ -37,6 +26,10 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.4.4 hooks: + - id: ruff + name: ruff lint + types: [python] + args: [--exit-non-zero-on-fix] - id: ruff-format types: [python] - repo: https://github.com/PyCQA/flake8 diff --git a/example_scenes/advanced_tex_fonts.py b/example_scenes/advanced_tex_fonts.py index 63edb06039..c5ecaa6078 100644 --- a/example_scenes/advanced_tex_fonts.py +++ b/example_scenes/advanced_tex_fonts.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from manim import * # French Cursive LaTeX font example from http://jf.burnol.free.fr/showcase.html diff --git a/example_scenes/basic.py b/example_scenes/basic.py index 6e8c866f49..bc5a45f18a 100644 --- a/example_scenes/basic.py +++ b/example_scenes/basic.py @@ -1,5 +1,5 @@ #!/usr/bin/env python - +from __future__ import annotations from manim import * diff --git a/example_scenes/customtex.py b/example_scenes/customtex.py index 62c37c5b3b..5e95d7722d 100644 --- a/example_scenes/customtex.py +++ b/example_scenes/customtex.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from manim import * diff --git a/example_scenes/opengl.py b/example_scenes/opengl.py index 27f579a6e4..030618e28b 100644 --- a/example_scenes/opengl.py +++ b/example_scenes/opengl.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from pathlib import Path import manim.utils.opengl as opengl diff --git a/manim/animation/indication.py b/manim/animation/indication.py index 8e2c3996c3..89bf506ebe 100644 --- a/manim/animation/indication.py +++ b/manim/animation/indication.py @@ -63,7 +63,6 @@ def construct(self): from ..mobject.types.vectorized_mobject import VGroup, VMobject from ..utils.bezier import interpolate, inverse_interpolate from ..utils.color import GREY, YELLOW, ParsableManimColor -from ..utils.deprecation import deprecated from ..utils.rate_functions import smooth, there_and_back, wiggle from ..utils.space_ops import normalize diff --git a/manim/cli/checkhealth/checks.py b/manim/cli/checkhealth/checks.py index 9859ced29f..dfc5f231a4 100644 --- a/manim/cli/checkhealth/checks.py +++ b/manim/cli/checkhealth/checks.py @@ -5,11 +5,8 @@ import os import shutil -import subprocess from typing import Callable -from ..._config import config - __all__ = ["HEALTH_CHECKS"] HEALTH_CHECKS = [] diff --git a/manim/cli/default_group.py b/manim/cli/default_group.py index 06f1c0520a..f4c8c33dbb 100644 --- a/manim/cli/default_group.py +++ b/manim/cli/default_group.py @@ -10,6 +10,8 @@ of ``click.Group``. """ +from __future__ import annotations + import warnings import cloup diff --git a/manim/mobject/graph.py b/manim/mobject/graph.py index 53d7ed464a..974f36a70b 100644 --- a/manim/mobject/graph.py +++ b/manim/mobject/graph.py @@ -477,7 +477,7 @@ def _determine_graph_layout( return cast(LayoutFunction, layout)( nx_graph, scale=layout_scale, **layout_config ) - except TypeError as e: + except TypeError: raise ValueError( f"The layout '{layout}' is neither a recognized layout, a layout function," "nor a vertex placement dictionary.", diff --git a/manim/mobject/opengl/opengl_surface.py b/manim/mobject/opengl/opengl_surface.py index bcf608909f..565b8c71cf 100644 --- a/manim/mobject/opengl/opengl_surface.py +++ b/manim/mobject/opengl/opengl_surface.py @@ -12,7 +12,6 @@ from manim.utils.bezier import integer_interpolate, interpolate from manim.utils.color import * from manim.utils.config_ops import _Data, _Uniforms -from manim.utils.deprecation import deprecated from manim.utils.images import change_to_rgba_array, get_full_raster_image_path from manim.utils.iterables import listify from manim.utils.space_ops import normalize_along_axis diff --git a/manim/mobject/text/code_mobject.py b/manim/mobject/text/code_mobject.py index e85f3bf0ba..b7aa6a7980 100644 --- a/manim/mobject/text/code_mobject.py +++ b/manim/mobject/text/code_mobject.py @@ -17,7 +17,6 @@ from pygments.lexers import get_lexer_by_name, guess_lexer_for_filename from pygments.styles import get_all_styles -from manim import logger from manim.constants import * from manim.mobject.geometry.arc import Dot from manim.mobject.geometry.polygram import RoundedRectangle diff --git a/manim/mobject/text/text_mobject.py b/manim/mobject/text/text_mobject.py index 39a1cdd171..6f7b4d9d9f 100644 --- a/manim/mobject/text/text_mobject.py +++ b/manim/mobject/text/text_mobject.py @@ -56,7 +56,6 @@ def construct(self): import copy import hashlib -import os import re from collections.abc import Iterable, Sequence from contextlib import contextmanager diff --git a/manim/mobject/three_d/three_dimensions.py b/manim/mobject/three_d/three_dimensions.py index 540a99bfe9..accb077746 100644 --- a/manim/mobject/three_d/three_dimensions.py +++ b/manim/mobject/three_d/three_dimensions.py @@ -34,14 +34,8 @@ from manim.mobject.opengl.opengl_mobject import OpenGLMobject from manim.mobject.types.vectorized_mobject import VGroup, VMobject from manim.utils.color import ( - BLUE, - BLUE_D, - BLUE_E, - LIGHT_GREY, - WHITE, ManimColor, ParsableManimColor, - interpolate_color, ) from manim.utils.iterables import tuplify from manim.utils.space_ops import normalize, perpendicular_bisector, z_to_vector diff --git a/manim/renderer/opengl_renderer.py b/manim/renderer/opengl_renderer.py index 5a4d692657..59c677f8e7 100644 --- a/manim/renderer/opengl_renderer.py +++ b/manim/renderer/opengl_renderer.py @@ -1,7 +1,6 @@ from __future__ import annotations import itertools as it -import sys import time from functools import cached_property from typing import Any diff --git a/manim/scene/scene.py b/manim/scene/scene.py index 1f5faed4ec..3f80c91864 100644 --- a/manim/scene/scene.py +++ b/manim/scene/scene.py @@ -230,7 +230,7 @@ def render(self, preview: bool = False): self.construct() except EndSceneEarlyException: pass - except RerunSceneException as e: + except RerunSceneException: self.remove(*self.mobjects) self.renderer.clear_screen() self.renderer.num_plays = 0 diff --git a/manim/utils/bezier.py b/manim/utils/bezier.py index 709f8b3bf4..806a1b24f5 100644 --- a/manim/utils/bezier.py +++ b/manim/utils/bezier.py @@ -9,8 +9,6 @@ Point3D, Point3D_Array, PointDType, - QuadraticBezierPoints, - QuadraticBezierPoints_Array, ) __all__ = [ diff --git a/manim/utils/color/AS2700.py b/manim/utils/color/AS2700.py index 83a3e6abd0..7b6dc6256c 100644 --- a/manim/utils/color/AS2700.py +++ b/manim/utils/color/AS2700.py @@ -24,6 +24,8 @@ """ +from __future__ import annotations + from .core import ManimColor B11_RICH_BLUE = ManimColor("#2B3770") diff --git a/manim/utils/color/BS381.py b/manim/utils/color/BS381.py index 50ae95b96c..60e8567a50 100644 --- a/manim/utils/color/BS381.py +++ b/manim/utils/color/BS381.py @@ -25,6 +25,8 @@ """ +from __future__ import annotations + from .core import ManimColor BS381_101 = ManimColor("#94BFAC") diff --git a/manim/utils/color/X11.py b/manim/utils/color/X11.py index 0379717eac..4338660200 100644 --- a/manim/utils/color/X11.py +++ b/manim/utils/color/X11.py @@ -23,6 +23,8 @@ .. automanimcolormodule:: manim.utils.color.X11 """ +from __future__ import annotations + from .core import ManimColor ALICEBLUE = ManimColor("#F0F8FF") diff --git a/manim/utils/color/XKCD.py b/manim/utils/color/XKCD.py index db9bccaed3..4c38af6862 100644 --- a/manim/utils/color/XKCD.py +++ b/manim/utils/color/XKCD.py @@ -24,6 +24,8 @@ """ +from __future__ import annotations + from .core import ManimColor ACIDGREEN = ManimColor("#8FFE09") diff --git a/manim/utils/color/__init__.py b/manim/utils/color/__init__.py index cfffc4edc9..fdde0ebb86 100644 --- a/manim/utils/color/__init__.py +++ b/manim/utils/color/__init__.py @@ -47,6 +47,8 @@ """ +from __future__ import annotations + from typing import Dict, List from . import AS2700, BS381, X11, XKCD diff --git a/manim/utils/color/manim_colors.py b/manim/utils/color/manim_colors.py index 863cb5a99f..a3eacc83a4 100644 --- a/manim/utils/color/manim_colors.py +++ b/manim/utils/color/manim_colors.py @@ -121,7 +121,7 @@ def named_lines_group(length, colors, names, text_colors, align_to_block): """ -from typing import List +from __future__ import annotations from .core import ManimColor diff --git a/manim/utils/docbuild/autoaliasattr_directive.py b/manim/utils/docbuild/autoaliasattr_directive.py index 6dd645a9fd..f6985788f2 100644 --- a/manim/utils/docbuild/autoaliasattr_directive.py +++ b/manim/utils/docbuild/autoaliasattr_directive.py @@ -12,7 +12,6 @@ if TYPE_CHECKING: from sphinx.application import Sphinx - from typing_extensions import TypeAlias __all__ = ["AliasAttrDocumenter"] diff --git a/manim/utils/docbuild/manim_directive.py b/manim/utils/docbuild/manim_directive.py index 111b40fa4d..8b65293956 100644 --- a/manim/utils/docbuild/manim_directive.py +++ b/manim/utils/docbuild/manim_directive.py @@ -82,7 +82,6 @@ def construct(self): import csv import itertools as it -import os import re import shutil import sys diff --git a/manim/utils/ipython_magic.py b/manim/utils/ipython_magic.py index 7911da9cf3..601d4d6f8e 100644 --- a/manim/utils/ipython_magic.py +++ b/manim/utils/ipython_magic.py @@ -3,13 +3,12 @@ from __future__ import annotations import mimetypes -import os import shutil from datetime import datetime from pathlib import Path from typing import Any -from manim import Group, config, logger, tempconfig +from manim import config, logger, tempconfig from manim.__main__ import main from manim.renderer.shader import shader_program_cache diff --git a/manim/utils/module_ops.py b/manim/utils/module_ops.py index 2ff7291470..03f297030d 100644 --- a/manim/utils/module_ops.py +++ b/manim/utils/module_ops.py @@ -2,7 +2,6 @@ import importlib.util import inspect -import os import re import sys import types diff --git a/manim/utils/simple_functions.py b/manim/utils/simple_functions.py index 72a0f8ddbd..898c1d527b 100644 --- a/manim/utils/simple_functions.py +++ b/manim/utils/simple_functions.py @@ -10,9 +10,7 @@ ] -import inspect from functools import lru_cache -from types import MappingProxyType from typing import Callable import numpy as np diff --git a/manim/utils/space_ops.py b/manim/utils/space_ops.py index ec47d136eb..197621fce6 100644 --- a/manim/utils/space_ops.py +++ b/manim/utils/space_ops.py @@ -10,7 +10,7 @@ from mapbox_earcut import triangulate_float32 as earcut from scipy.spatial.transform import Rotation -from manim.constants import DOWN, OUT, PI, RIGHT, TAU, UP, RendererType +from manim.constants import DOWN, OUT, PI, RIGHT, TAU, UP from manim.utils.iterables import adjacent_pairs if TYPE_CHECKING: diff --git a/pyproject.toml b/pyproject.toml index 7b05d004df..4aaf254a81 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -134,6 +134,31 @@ extend-exclude = [ ] fix = true +[tool.ruff.lint] +extend-select = [ + "I", +] + +extend-ignore = [ + # due to the import * used in manim + "F403", + "F405", +] + +[tool.ruff.lint.per-file-ignores] +"tests/*" = [ + # unused variable + "F841", +] + +"__init__.py" = [ + "F401", + "F403", +] + +[tool.ruff.lint.isort] +required-imports = ["from __future__ import annotations"] + [tool.ruff.format] docstring-code-format = true diff --git a/scripts/extract_frames.py b/scripts/extract_frames.py index d3c7691895..a8900de5c0 100644 --- a/scripts/extract_frames.py +++ b/scripts/extract_frames.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pathlib import sys diff --git a/tests/interface/test_commands.py b/tests/interface/test_commands.py index d902d3b07b..c6223a78cb 100644 --- a/tests/interface/test_commands.py +++ b/tests/interface/test_commands.py @@ -8,7 +8,7 @@ from click.testing import CliRunner -from manim import __version__, capture, tempconfig +from manim import __version__, capture from manim.__main__ import main from manim.cli.checkhealth.checks import HEALTH_CHECKS diff --git a/tests/module/mobject/graphing/test_coordinate_system.py b/tests/module/mobject/graphing/test_coordinate_system.py index fd86a9bd4d..880ec0a3c0 100644 --- a/tests/module/mobject/graphing/test_coordinate_system.py +++ b/tests/module/mobject/graphing/test_coordinate_system.py @@ -5,9 +5,21 @@ import numpy as np import pytest -from manim import LEFT, ORIGIN, PI, UR, Axes, Circle, ComplexPlane +from manim import ( + LEFT, + ORIGIN, + PI, + UR, + Axes, + Circle, + ComplexPlane, + NumberPlane, + PolarPlane, + ThreeDAxes, + config, + tempconfig, +) from manim import CoordinateSystem as CS -from manim import NumberPlane, PolarPlane, ThreeDAxes, config, tempconfig def test_initial_config(): diff --git a/tests/module/mobject/test_image.py b/tests/module/mobject/test_image.py index a79fce5b8a..958871bf74 100644 --- a/tests/module/mobject/test_image.py +++ b/tests/module/mobject/test_image.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import numpy as np import pytest diff --git a/tests/module/mobject/text/test_texmobject.py b/tests/module/mobject/text/test_texmobject.py index 9f487be4e8..c8d4f51f84 100644 --- a/tests/module/mobject/text/test_texmobject.py +++ b/tests/module/mobject/text/test_texmobject.py @@ -6,8 +6,6 @@ import pytest from manim import MathTex, SingleStringMathTex, Tex, TexTemplate, config, tempconfig -from manim.mobject.types.vectorized_mobject import VMobject -from manim.utils.color import RED def test_MathTex(): diff --git a/tests/module/mobject/types/vectorized_mobject/test_vectorized_mobject.py b/tests/module/mobject/types/vectorized_mobject/test_vectorized_mobject.py index 7e92a68ac8..bf91c0fef4 100644 --- a/tests/module/mobject/types/vectorized_mobject/test_vectorized_mobject.py +++ b/tests/module/mobject/types/vectorized_mobject/test_vectorized_mobject.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from math import cos, sin import numpy as np diff --git a/tests/module/scene/test_threed_scene.py b/tests/module/scene/test_threed_scene.py index 24f6f26330..b3d9e068a7 100644 --- a/tests/module/scene/test_threed_scene.py +++ b/tests/module/scene/test_threed_scene.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from manim import Circle, Square, ThreeDScene diff --git a/tests/module/utils/_split_matrices.py b/tests/module/utils/_split_matrices.py index 70c87497e6..9ceb1ff27d 100644 --- a/tests/module/utils/_split_matrices.py +++ b/tests/module/utils/_split_matrices.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import numpy as np # Defined because pre-commit is inserting an unacceptable line-break diff --git a/tests/module/utils/_subdivision_matrices.py b/tests/module/utils/_subdivision_matrices.py index c020937dea..057daa2ff0 100644 --- a/tests/module/utils/_subdivision_matrices.py +++ b/tests/module/utils/_subdivision_matrices.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import numpy as np # Expected values for matrices in subdivide_bezier and others diff --git a/tests/module/utils/test_space_ops.py b/tests/module/utils/test_space_ops.py index eef307b4b6..13584c797d 100644 --- a/tests/module/utils/test_space_ops.py +++ b/tests/module/utils/test_space_ops.py @@ -4,7 +4,7 @@ import pytest from manim.utils.space_ops import * -from manim.utils.space_ops import shoelace, shoelace_direction +from manim.utils.space_ops import shoelace def test_rotate_vector(): diff --git a/tests/module/utils/test_tex.py b/tests/module/utils/test_tex.py index 51666168e0..7d56ff54a2 100644 --- a/tests/module/utils/test_tex.py +++ b/tests/module/utils/test_tex.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import pytest from manim.utils.tex import TexTemplate diff --git a/tests/opengl/test_coordinate_system_opengl.py b/tests/opengl/test_coordinate_system_opengl.py index 603f8eba54..ed596d7e9d 100644 --- a/tests/opengl/test_coordinate_system_opengl.py +++ b/tests/opengl/test_coordinate_system_opengl.py @@ -5,9 +5,21 @@ import numpy as np import pytest -from manim import LEFT, ORIGIN, PI, UR, Axes, Circle, ComplexPlane +from manim import ( + LEFT, + ORIGIN, + PI, + UR, + Axes, + Circle, + ComplexPlane, + NumberPlane, + PolarPlane, + ThreeDAxes, + config, + tempconfig, +) from manim import CoordinateSystem as CS -from manim import NumberPlane, PolarPlane, ThreeDAxes, config, tempconfig def test_initial_config(using_opengl_renderer): diff --git a/tests/opengl/test_opengl_surface.py b/tests/opengl/test_opengl_surface.py index d6897691d4..dc54ea6e64 100644 --- a/tests/opengl/test_opengl_surface.py +++ b/tests/opengl/test_opengl_surface.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import numpy as np from manim.mobject.opengl.opengl_surface import OpenGLSurface diff --git a/tests/test_code_mobject.py b/tests/test_code_mobject.py index b4b522a107..28e22ef9f5 100644 --- a/tests/test_code_mobject.py +++ b/tests/test_code_mobject.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from manim.mobject.text.code_mobject import Code diff --git a/tests/test_config.py b/tests/test_config.py index ed2f4b59c0..21e0da2d1b 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -1,6 +1,5 @@ from __future__ import annotations -import os import tempfile from pathlib import Path diff --git a/tests/test_graphical_units/test_probability.py b/tests/test_graphical_units/test_probability.py index f5e31c95c8..36496dee38 100644 --- a/tests/test_graphical_units/test_probability.py +++ b/tests/test_graphical_units/test_probability.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from manim.constants import LEFT from manim.mobject.graphing.probability import BarChart from manim.mobject.text.tex_mobject import MathTex diff --git a/tests/test_graphical_units/test_tex_mobject.py b/tests/test_graphical_units/test_tex_mobject.py index d92162b379..3dc16f5b96 100644 --- a/tests/test_graphical_units/test_tex_mobject.py +++ b/tests/test_graphical_units/test_tex_mobject.py @@ -1,4 +1,4 @@ -import pytest +from __future__ import annotations from manim import * from manim.utils.testing.frames_comparison import frames_comparison diff --git a/tests/test_graphical_units/test_text.py b/tests/test_graphical_units/test_text.py index 21649222be..a992c521be 100644 --- a/tests/test_graphical_units/test_text.py +++ b/tests/test_graphical_units/test_text.py @@ -1,6 +1,6 @@ -import pytest +from __future__ import annotations -from manim import RED, MarkupText, Text, VGroup, VMobject +from manim import RED, MarkupText, Text, VMobject __module_test__ = "text" diff --git a/tests/test_linear_transformation_scene.py b/tests/test_linear_transformation_scene.py index c45e3f6997..fae9518610 100644 --- a/tests/test_linear_transformation_scene.py +++ b/tests/test_linear_transformation_scene.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from manim import RIGHT, UP, LinearTransformationScene, Vector, VGroup __module_test__ = "vector_space_scene" diff --git a/tests/test_logging/bad_tex_scene.py b/tests/test_logging/bad_tex_scene.py index d8ec0a286a..31847eccad 100644 --- a/tests/test_logging/bad_tex_scene.py +++ b/tests/test_logging/bad_tex_scene.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from manim import Scene, Tex, TexTemplate diff --git a/tests/test_scene_rendering/test_file_writer.py b/tests/test_scene_rendering/test_file_writer.py index 6ccc8b25d0..cbbe1a9a35 100644 --- a/tests/test_scene_rendering/test_file_writer.py +++ b/tests/test_scene_rendering/test_file_writer.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import sys from pathlib import Path From e65d42dfc6cae3982eece94d4674b774f93e8c92 Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Wed, 22 May 2024 12:32:13 -0400 Subject: [PATCH 02/16] Fix ruff linting errors --- conftest.py | 2 +- manim/mobject/graph.py | 1 + manim/mobject/graphing/scale.py | 10 +++++-- manim/mobject/opengl/opengl_mobject.py | 28 +------------------ manim/renderer/opengl_renderer.py | 2 +- manim/utils/bezier.py | 28 +++++++++++-------- .../utils/docbuild/autoaliasattr_directive.py | 4 ++- manim/utils/docbuild/module_parsing.py | 1 + manim/utils/file_ops.py | 2 +- scripts/dev_changelog.py | 1 - .../mobject/geometry/test_unit_geometry.py | 4 +-- tests/test_config.py | 1 - tests/test_graphical_units/test_axes.py | 5 +++- 13 files changed, 40 insertions(+), 49 deletions(-) diff --git a/conftest.py b/conftest.py index dacb730a29..0e42c40317 100644 --- a/conftest.py +++ b/conftest.py @@ -7,7 +7,7 @@ try: # https://github.com/moderngl/moderngl/issues/517 - import readline # required to prevent a segfault on Python 3.10 + import readline # required to prevent a segfault on Python 3.10 # noqa: F401 except ModuleNotFoundError: # windows pass diff --git a/manim/mobject/graph.py b/manim/mobject/graph.py index 974f36a70b..d54c1e0457 100644 --- a/manim/mobject/graph.py +++ b/manim/mobject/graph.py @@ -18,6 +18,7 @@ if TYPE_CHECKING: from typing_extensions import TypeAlias + from manim.scene.scene import Scene from manim.typing import Point3D NxGraph: TypeAlias = nx.classes.graph.Graph | nx.classes.digraph.DiGraph diff --git a/manim/mobject/graphing/scale.py b/manim/mobject/graphing/scale.py index b301d1ff15..e2101d1478 100644 --- a/manim/mobject/graphing/scale.py +++ b/manim/mobject/graphing/scale.py @@ -144,12 +144,18 @@ def function(self, value: float) -> float: def inverse_function(self, value: float) -> float: """Inverse of ``function``. The value must be greater than 0""" + + def func(value, base): + return ( + np.log(value) / np.log(base) + if isinstance(value, np.ndarray) + else math.log + ) + if isinstance(value, np.ndarray): condition = value.any() <= 0 - func = lambda value, base: np.log(value) / np.log(base) else: condition = value <= 0 - func = math.log if condition: raise ValueError( diff --git a/manim/mobject/opengl/opengl_mobject.py b/manim/mobject/opengl/opengl_mobject.py index 3bdbd7c0b5..dbdca251c5 100644 --- a/manim/mobject/opengl/opengl_mobject.py +++ b/manim/mobject/opengl/opengl_mobject.py @@ -976,7 +976,7 @@ def construct(self): if recursive: for submob in self.submobjects: submob.invert(recursive=True) - list.reverse(self.submobjects) + self.submobjects.reverse() self.assemble_family() # Submobject organization @@ -1295,32 +1295,6 @@ def construct(self): self.assemble_family() return self - def invert(self, recursive=False): - """Inverts the list of :attr:`submobjects`. - - Parameters - ---------- - recursive - If ``True``, all submobject lists of this mobject's family are inverted. - - Examples - -------- - - .. manim:: InvertSumobjectsExample - - class InvertSumobjectsExample(Scene): - def construct(self): - s = VGroup(*[Dot().shift(i*0.1*RIGHT) for i in range(-20,20)]) - s2 = s.copy() - s2.invert() - s2.shift(DOWN) - self.play(Write(s), Write(s2)) - """ - if recursive: - for submob in self.submobjects: - submob.invert(recursive=True) - list.reverse(self.submobjects) - # Copying def copy(self, shallow: bool = False): diff --git a/manim/renderer/opengl_renderer.py b/manim/renderer/opengl_renderer.py index 59c677f8e7..8347f8a49e 100644 --- a/manim/renderer/opengl_renderer.py +++ b/manim/renderer/opengl_renderer.py @@ -568,7 +568,7 @@ def pixel_coords_to_space_coords(self, px, py, relative=False, top_left=False): if pixel_shape is None: return np.array([0, 0, 0]) pw, ph = pixel_shape - fw, fh = config["frame_width"], config["frame_height"] + fh = config["frame_height"] fc = self.camera.get_center() if relative: return 2 * np.array([px / pw, py / ph, 0]) diff --git a/manim/utils/bezier.py b/manim/utils/bezier.py index 806a1b24f5..abf67b5f30 100644 --- a/manim/utils/bezier.py +++ b/manim/utils/bezier.py @@ -2,15 +2,6 @@ from __future__ import annotations -from manim.typing import ( - BezierPoints, - ColVector, - MatrixMN, - Point3D, - Point3D_Array, - PointDType, -) - __all__ = [ "bezier", "partial_bezier_points", @@ -33,15 +24,30 @@ from collections.abc import Sequence from functools import reduce -from typing import Any, Callable, overload +from typing import TYPE_CHECKING, Any, Callable, overload import numpy as np -import numpy.typing as npt from scipy import linalg from ..utils.simple_functions import choose from ..utils.space_ops import cross2d, find_intersection +if TYPE_CHECKING: + import numpy.typing as npt + + from manim.typing import ( + BezierPoints, + BezierPoints_Array, + ColVector, + MatrixMN, + Point3D, + Point3D_Array, + PointDType, + ) + +# l is a commonly used name in linear algebra +# ruff: noqa: E741 + def bezier( points: Sequence[Point3D] | Point3D_Array, diff --git a/manim/utils/docbuild/autoaliasattr_directive.py b/manim/utils/docbuild/autoaliasattr_directive.py index f6985788f2..7d741ab84c 100644 --- a/manim/utils/docbuild/autoaliasattr_directive.py +++ b/manim/utils/docbuild/autoaliasattr_directive.py @@ -48,7 +48,9 @@ def smart_replace(base: str, alias: str, substitution: str) -> str: occurrences = [] len_alias = len(alias) len_base = len(base) - condition = lambda char: (not char.isalnum()) and char != "_" + + def condition(char: str): + return not char.isalnum() and char != "_" start = 0 i = 0 diff --git a/manim/utils/docbuild/module_parsing.py b/manim/utils/docbuild/module_parsing.py index 87bfa76c40..5166ff4801 100644 --- a/manim/utils/docbuild/module_parsing.py +++ b/manim/utils/docbuild/module_parsing.py @@ -47,6 +47,7 @@ # In the following, we will use ``type(xyz) is xyz_type`` instead of # isinstance checks to make sure no subclasses of the type pass the # check +# ruff: noqa: E721 def parse_module_attributes() -> tuple[AliasDocsDict, DataDict]: diff --git a/manim/utils/file_ops.py b/manim/utils/file_ops.py index 58c82464a1..7efcee02c5 100644 --- a/manim/utils/file_ops.py +++ b/manim/utils/file_ops.py @@ -32,7 +32,7 @@ from manim import __version__, config, logger -from .. import config, console +from .. import console def is_mp4_format() -> bool: diff --git a/scripts/dev_changelog.py b/scripts/dev_changelog.py index d226b0195f..35e77dd798 100755 --- a/scripts/dev_changelog.py +++ b/scripts/dev_changelog.py @@ -301,7 +301,6 @@ def main(token, prior, tag, additional, outfile): for PR in pr_by_labels[label]: num = PR.number - url = PR.html_url title = PR.title label = PR.labels f.write(f"* :pr:`{num}`: {title}\n") diff --git a/tests/module/mobject/geometry/test_unit_geometry.py b/tests/module/mobject/geometry/test_unit_geometry.py index 1729752fff..45f4da279f 100644 --- a/tests/module/mobject/geometry/test_unit_geometry.py +++ b/tests/module/mobject/geometry/test_unit_geometry.py @@ -4,10 +4,10 @@ import numpy as np -logger = logging.getLogger(__name__) - from manim import BackgroundRectangle, Circle, Sector +logger = logging.getLogger(__name__) + def test_get_arc_center(): np.testing.assert_array_equal( diff --git a/tests/test_config.py b/tests/test_config.py index 21e0da2d1b..0c60d59b10 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -102,7 +102,6 @@ def test_custom_dirs(tmp_path): "frame_rate": 15, "pixel_height": 854, "pixel_width": 480, - "save_sections": True, "sections_dir": "{media_dir}/test_sections", "video_dir": "{media_dir}/test_video", "partial_movie_dir": "{media_dir}/test_partial_movie_dir", diff --git a/tests/test_graphical_units/test_axes.py b/tests/test_graphical_units/test_axes.py index 8e450511d2..2e06300e46 100644 --- a/tests/test_graphical_units/test_axes.py +++ b/tests/test_graphical_units/test_axes.py @@ -293,7 +293,10 @@ def test_get_z_axis_label(scene): @frames_comparison def test_polar_graph(scene): polar = PolarPlane() - r = lambda theta: 4 * np.sin(theta * 4) + + def r(theta): + return 4 * np.sin(theta * 4) + polar_graph = polar.plot_polar_graph(r) scene.add(polar, polar_graph) From cfb49d39c8c7e67cad415295b7a7abff39b7b4d3 Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Wed, 22 May 2024 12:37:10 -0400 Subject: [PATCH 03/16] fix test --- manim/utils/bezier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manim/utils/bezier.py b/manim/utils/bezier.py index abf67b5f30..556981e9b9 100644 --- a/manim/utils/bezier.py +++ b/manim/utils/bezier.py @@ -29,6 +29,7 @@ import numpy as np from scipy import linalg +from manim.typing import PointDType from ..utils.simple_functions import choose from ..utils.space_ops import cross2d, find_intersection @@ -42,7 +43,6 @@ MatrixMN, Point3D, Point3D_Array, - PointDType, ) # l is a commonly used name in linear algebra From 9b6fcd89c926433f12168409ddde366dad7b60fc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 22 May 2024 16:37:52 +0000 Subject: [PATCH 04/16] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- manim/utils/bezier.py | 1 + 1 file changed, 1 insertion(+) diff --git a/manim/utils/bezier.py b/manim/utils/bezier.py index 556981e9b9..ed1c659b4c 100644 --- a/manim/utils/bezier.py +++ b/manim/utils/bezier.py @@ -30,6 +30,7 @@ from scipy import linalg from manim.typing import PointDType + from ..utils.simple_functions import choose from ..utils.space_ops import cross2d, find_intersection From dd2075c7645ed54afb2dc6f81ede405b91057997 Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Wed, 22 May 2024 16:16:35 -0400 Subject: [PATCH 05/16] try fixing tests again? --- manim/mobject/graphing/scale.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/manim/mobject/graphing/scale.py b/manim/mobject/graphing/scale.py index e2101d1478..649d9f562e 100644 --- a/manim/mobject/graphing/scale.py +++ b/manim/mobject/graphing/scale.py @@ -144,18 +144,13 @@ def function(self, value: float) -> float: def inverse_function(self, value: float) -> float: """Inverse of ``function``. The value must be greater than 0""" - - def func(value, base): - return ( - np.log(value) / np.log(base) - if isinstance(value, np.ndarray) - else math.log - ) - if isinstance(value, np.ndarray): condition = value.any() <= 0 + def func(value, base): + return np.log(value) / np.log(base) else: condition = value <= 0 + func = math.log if condition: raise ValueError( From 56e77ce232ceb748768b16a9736d5f67c89472cb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 22 May 2024 20:18:32 +0000 Subject: [PATCH 06/16] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- manim/mobject/graphing/scale.py | 1 + 1 file changed, 1 insertion(+) diff --git a/manim/mobject/graphing/scale.py b/manim/mobject/graphing/scale.py index 649d9f562e..5a3a30410b 100644 --- a/manim/mobject/graphing/scale.py +++ b/manim/mobject/graphing/scale.py @@ -146,6 +146,7 @@ def inverse_function(self, value: float) -> float: """Inverse of ``function``. The value must be greater than 0""" if isinstance(value, np.ndarray): condition = value.any() <= 0 + def func(value, base): return np.log(value) / np.log(base) else: From 8d74be00079483fee7ac896e5a3d8fd6a9f0d665 Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Wed, 22 May 2024 16:32:42 -0400 Subject: [PATCH 07/16] undo changes in test --- pyproject.toml | 2 ++ tests/module/mobject/test_image.py | 2 -- .../mobject/types/vectorized_mobject/test_vectorized_mobject.py | 2 -- tests/module/scene/test_threed_scene.py | 2 -- tests/module/utils/_split_matrices.py | 2 -- tests/module/utils/_subdivision_matrices.py | 2 -- tests/module/utils/test_tex.py | 2 -- 7 files changed, 2 insertions(+), 12 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4aaf254a81..16afa5c845 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -149,6 +149,8 @@ extend-ignore = [ "tests/*" = [ # unused variable "F841", + # from __future__ import annotations + "I002", ] "__init__.py" = [ diff --git a/tests/module/mobject/test_image.py b/tests/module/mobject/test_image.py index 958871bf74..a79fce5b8a 100644 --- a/tests/module/mobject/test_image.py +++ b/tests/module/mobject/test_image.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import numpy as np import pytest diff --git a/tests/module/mobject/types/vectorized_mobject/test_vectorized_mobject.py b/tests/module/mobject/types/vectorized_mobject/test_vectorized_mobject.py index bf91c0fef4..7e92a68ac8 100644 --- a/tests/module/mobject/types/vectorized_mobject/test_vectorized_mobject.py +++ b/tests/module/mobject/types/vectorized_mobject/test_vectorized_mobject.py @@ -1,5 +1,3 @@ -from __future__ import annotations - from math import cos, sin import numpy as np diff --git a/tests/module/scene/test_threed_scene.py b/tests/module/scene/test_threed_scene.py index b3d9e068a7..24f6f26330 100644 --- a/tests/module/scene/test_threed_scene.py +++ b/tests/module/scene/test_threed_scene.py @@ -1,5 +1,3 @@ -from __future__ import annotations - from manim import Circle, Square, ThreeDScene diff --git a/tests/module/utils/_split_matrices.py b/tests/module/utils/_split_matrices.py index 9ceb1ff27d..70c87497e6 100644 --- a/tests/module/utils/_split_matrices.py +++ b/tests/module/utils/_split_matrices.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import numpy as np # Defined because pre-commit is inserting an unacceptable line-break diff --git a/tests/module/utils/_subdivision_matrices.py b/tests/module/utils/_subdivision_matrices.py index 057daa2ff0..c020937dea 100644 --- a/tests/module/utils/_subdivision_matrices.py +++ b/tests/module/utils/_subdivision_matrices.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import numpy as np # Expected values for matrices in subdivide_bezier and others diff --git a/tests/module/utils/test_tex.py b/tests/module/utils/test_tex.py index 7d56ff54a2..51666168e0 100644 --- a/tests/module/utils/test_tex.py +++ b/tests/module/utils/test_tex.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import pytest from manim.utils.tex import TexTemplate From 832dca3be5902e6c63c65ba8db7ed53a391df160 Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Wed, 22 May 2024 16:35:45 -0400 Subject: [PATCH 08/16] Don't add __future__ to example scenes --- example_scenes/advanced_tex_fonts.py | 2 -- example_scenes/basic.py | 2 +- example_scenes/customtex.py | 2 -- example_scenes/opengl.py | 2 -- pyproject.toml | 4 ++++ 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/example_scenes/advanced_tex_fonts.py b/example_scenes/advanced_tex_fonts.py index c5ecaa6078..63edb06039 100644 --- a/example_scenes/advanced_tex_fonts.py +++ b/example_scenes/advanced_tex_fonts.py @@ -1,5 +1,3 @@ -from __future__ import annotations - from manim import * # French Cursive LaTeX font example from http://jf.burnol.free.fr/showcase.html diff --git a/example_scenes/basic.py b/example_scenes/basic.py index bc5a45f18a..6e8c866f49 100644 --- a/example_scenes/basic.py +++ b/example_scenes/basic.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -from __future__ import annotations + from manim import * diff --git a/example_scenes/customtex.py b/example_scenes/customtex.py index 5e95d7722d..62c37c5b3b 100644 --- a/example_scenes/customtex.py +++ b/example_scenes/customtex.py @@ -1,5 +1,3 @@ -from __future__ import annotations - from manim import * diff --git a/example_scenes/opengl.py b/example_scenes/opengl.py index 030618e28b..27f579a6e4 100644 --- a/example_scenes/opengl.py +++ b/example_scenes/opengl.py @@ -1,5 +1,3 @@ -from __future__ import annotations - from pathlib import Path import manim.utils.opengl as opengl diff --git a/pyproject.toml b/pyproject.toml index 16afa5c845..f2281a2ace 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -153,6 +153,10 @@ extend-ignore = [ "I002", ] +"example_scenes/*" = [ + "I002", +] + "__init__.py" = [ "F401", "F403", From 6ace83ab6b405cb1d9b1bc6a9784db6556041059 Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Wed, 22 May 2024 16:42:57 -0400 Subject: [PATCH 09/16] Fixed missed imports --- tests/opengl/test_opengl_surface.py | 2 -- tests/test_code_mobject.py | 2 -- tests/test_graphical_units/test_axes.py | 2 -- tests/test_graphical_units/test_probability.py | 2 -- tests/test_graphical_units/test_tex_mobject.py | 2 -- tests/test_graphical_units/test_text.py | 2 -- tests/test_linear_transformation_scene.py | 2 -- tests/test_logging/bad_tex_scene.py | 2 -- tests/test_scene_rendering/test_file_writer.py | 2 -- 9 files changed, 18 deletions(-) diff --git a/tests/opengl/test_opengl_surface.py b/tests/opengl/test_opengl_surface.py index dc54ea6e64..d6897691d4 100644 --- a/tests/opengl/test_opengl_surface.py +++ b/tests/opengl/test_opengl_surface.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import numpy as np from manim.mobject.opengl.opengl_surface import OpenGLSurface diff --git a/tests/test_code_mobject.py b/tests/test_code_mobject.py index 28e22ef9f5..b4b522a107 100644 --- a/tests/test_code_mobject.py +++ b/tests/test_code_mobject.py @@ -1,5 +1,3 @@ -from __future__ import annotations - from manim.mobject.text.code_mobject import Code diff --git a/tests/test_graphical_units/test_axes.py b/tests/test_graphical_units/test_axes.py index 2e06300e46..f6e5e15675 100644 --- a/tests/test_graphical_units/test_axes.py +++ b/tests/test_graphical_units/test_axes.py @@ -293,10 +293,8 @@ def test_get_z_axis_label(scene): @frames_comparison def test_polar_graph(scene): polar = PolarPlane() - def r(theta): return 4 * np.sin(theta * 4) - polar_graph = polar.plot_polar_graph(r) scene.add(polar, polar_graph) diff --git a/tests/test_graphical_units/test_probability.py b/tests/test_graphical_units/test_probability.py index 36496dee38..f5e31c95c8 100644 --- a/tests/test_graphical_units/test_probability.py +++ b/tests/test_graphical_units/test_probability.py @@ -1,5 +1,3 @@ -from __future__ import annotations - from manim.constants import LEFT from manim.mobject.graphing.probability import BarChart from manim.mobject.text.tex_mobject import MathTex diff --git a/tests/test_graphical_units/test_tex_mobject.py b/tests/test_graphical_units/test_tex_mobject.py index 3dc16f5b96..b229e1cb0f 100644 --- a/tests/test_graphical_units/test_tex_mobject.py +++ b/tests/test_graphical_units/test_tex_mobject.py @@ -1,5 +1,3 @@ -from __future__ import annotations - from manim import * from manim.utils.testing.frames_comparison import frames_comparison diff --git a/tests/test_graphical_units/test_text.py b/tests/test_graphical_units/test_text.py index a992c521be..ab5d4fbeb1 100644 --- a/tests/test_graphical_units/test_text.py +++ b/tests/test_graphical_units/test_text.py @@ -1,5 +1,3 @@ -from __future__ import annotations - from manim import RED, MarkupText, Text, VMobject __module_test__ = "text" diff --git a/tests/test_linear_transformation_scene.py b/tests/test_linear_transformation_scene.py index fae9518610..c45e3f6997 100644 --- a/tests/test_linear_transformation_scene.py +++ b/tests/test_linear_transformation_scene.py @@ -1,5 +1,3 @@ -from __future__ import annotations - from manim import RIGHT, UP, LinearTransformationScene, Vector, VGroup __module_test__ = "vector_space_scene" diff --git a/tests/test_logging/bad_tex_scene.py b/tests/test_logging/bad_tex_scene.py index 31847eccad..d8ec0a286a 100644 --- a/tests/test_logging/bad_tex_scene.py +++ b/tests/test_logging/bad_tex_scene.py @@ -1,5 +1,3 @@ -from __future__ import annotations - from manim import Scene, Tex, TexTemplate diff --git a/tests/test_scene_rendering/test_file_writer.py b/tests/test_scene_rendering/test_file_writer.py index cbbe1a9a35..6ccc8b25d0 100644 --- a/tests/test_scene_rendering/test_file_writer.py +++ b/tests/test_scene_rendering/test_file_writer.py @@ -1,5 +1,3 @@ -from __future__ import annotations - import sys from pathlib import Path From 97752677e1909a32b3ef3991f61118030dd1831f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 22 May 2024 20:44:36 +0000 Subject: [PATCH 10/16] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_graphical_units/test_axes.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test_graphical_units/test_axes.py b/tests/test_graphical_units/test_axes.py index f6e5e15675..2e06300e46 100644 --- a/tests/test_graphical_units/test_axes.py +++ b/tests/test_graphical_units/test_axes.py @@ -293,8 +293,10 @@ def test_get_z_axis_label(scene): @frames_comparison def test_polar_graph(scene): polar = PolarPlane() + def r(theta): return 4 * np.sin(theta * 4) + polar_graph = polar.plot_polar_graph(r) scene.add(polar, polar_graph) From 1f8565e94d2dbe07c10255566f02c5e331184514 Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Mon, 27 May 2024 20:16:20 -0400 Subject: [PATCH 11/16] Remove unused local variables --- manim/mobject/types/vectorized_mobject.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/manim/mobject/types/vectorized_mobject.py b/manim/mobject/types/vectorized_mobject.py index cc938065d3..328a8acce8 100644 --- a/manim/mobject/types/vectorized_mobject.py +++ b/manim/mobject/types/vectorized_mobject.py @@ -911,7 +911,6 @@ def add_line_to(self, point: Point3D) -> Self: :class:`VMobject` ``self`` """ - nppcc = self.n_points_per_cubic_curve self.add_cubic_bezier_curve_to( *( interpolate(self.get_last_point(), point, t) @@ -1060,7 +1059,6 @@ def construct(self): vmob.set_points_as_corners(corners).scale(2) self.add(vmob) """ - nppcc = self.n_points_per_cubic_curve points = np.array(points) # This will set the handles aligned with the anchors. # Id est, a bezier curve will be the segment from the two anchors such that the handles belongs to this segment. From 97fb50f467d9880dd9ac843276680399528dc48a Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Mon, 27 May 2024 20:45:19 -0400 Subject: [PATCH 12/16] Revert runtime change back --- manim/mobject/opengl/opengl_mobject.py | 54 +++++++++++++------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/manim/mobject/opengl/opengl_mobject.py b/manim/mobject/opengl/opengl_mobject.py index dbdca251c5..ac34e73509 100644 --- a/manim/mobject/opengl/opengl_mobject.py +++ b/manim/mobject/opengl/opengl_mobject.py @@ -952,33 +952,6 @@ def replace_submobject(self, index, new_submob): self.assemble_family() return self - def invert(self, recursive=False): - """Inverts the list of :attr:`submobjects`. - - Parameters - ---------- - recursive - If ``True``, all submobject lists of this mobject's family are inverted. - - Examples - -------- - - .. manim:: InvertSumobjectsExample - - class InvertSumobjectsExample(Scene): - def construct(self): - s = VGroup(*[Dot().shift(i*0.1*RIGHT) for i in range(-20,20)]) - s2 = s.copy() - s2.invert() - s2.shift(DOWN) - self.play(Write(s), Write(s2)) - """ - if recursive: - for submob in self.submobjects: - submob.invert(recursive=True) - self.submobjects.reverse() - self.assemble_family() - # Submobject organization def arrange(self, direction=RIGHT, center=True, **kwargs): @@ -1295,6 +1268,33 @@ def construct(self): self.assemble_family() return self + def invert(self, recursive=False): + """Inverts the list of :attr:`submobjects`. + + Parameters + ---------- + recursive + If ``True``, all submobject lists of this mobject's family are inverted. + + Examples + -------- + + .. manim:: InvertSumobjectsExample + + class InvertSumobjectsExample(Scene): + def construct(self): + s = VGroup(*[Dot().shift(i*0.1*RIGHT) for i in range(-20,20)]) + s2 = s.copy() + s2.invert() + s2.shift(DOWN) + self.play(Write(s), Write(s2)) + """ + if recursive: + for submob in self.submobjects: + submob.invert(recursive=True) + self.submobjects.reverse() + # Is there supposed to be an assemble_family here? + # Copying def copy(self, shallow: bool = False): From 223ade5fa4c73ba64fd78b44f221353166b3091d Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Mon, 27 May 2024 20:47:38 -0400 Subject: [PATCH 13/16] Remove typing import of Dict/List --- manim/utils/color/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/manim/utils/color/__init__.py b/manim/utils/color/__init__.py index fdde0ebb86..362a31ac25 100644 --- a/manim/utils/color/__init__.py +++ b/manim/utils/color/__init__.py @@ -49,8 +49,6 @@ from __future__ import annotations -from typing import Dict, List - from . import AS2700, BS381, X11, XKCD from .core import * from .manim_colors import * From 72cd57cebc1a422f3dc2eb4ce7169d2339a914ac Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Fri, 31 May 2024 07:55:29 -0400 Subject: [PATCH 14/16] Feedback --- pyproject.toml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f2281a2ace..ebf7a27b5d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -135,16 +135,26 @@ extend-exclude = [ fix = true [tool.ruff.lint] -extend-select = [ +select = [ + "E", + "F", "I", ] -extend-ignore = [ +ignore = [ # due to the import * used in manim "F403", "F405", + # as recommended by https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules + "E111", + "E114", + "E117", + "E501", ] +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + [tool.ruff.lint.per-file-ignores] "tests/*" = [ # unused variable From 94efe41cbf0ed3d89534eb31e171bf1d05151fe8 Mon Sep 17 00:00:00 2001 From: JasonGrace2282 Date: Fri, 31 May 2024 07:56:46 -0400 Subject: [PATCH 15/16] try removing import readline --- conftest.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/conftest.py b/conftest.py index 0e42c40317..683bd2bc05 100644 --- a/conftest.py +++ b/conftest.py @@ -5,12 +5,6 @@ from __future__ import annotations -try: - # https://github.com/moderngl/moderngl/issues/517 - import readline # required to prevent a segfault on Python 3.10 # noqa: F401 -except ModuleNotFoundError: # windows - pass - import cairo import moderngl From 04ef1412dab546dfa3bfdf6964cb4c3f60edc3b0 Mon Sep 17 00:00:00 2001 From: adeshpande <110117391+JasonGrace2282@users.noreply.github.com> Date: Fri, 31 May 2024 14:20:06 -0400 Subject: [PATCH 16/16] fully type helper function Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com> --- manim/utils/docbuild/autoaliasattr_directive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manim/utils/docbuild/autoaliasattr_directive.py b/manim/utils/docbuild/autoaliasattr_directive.py index 7d741ab84c..6cb4137833 100644 --- a/manim/utils/docbuild/autoaliasattr_directive.py +++ b/manim/utils/docbuild/autoaliasattr_directive.py @@ -49,7 +49,7 @@ def smart_replace(base: str, alias: str, substitution: str) -> str: len_alias = len(alias) len_base = len(base) - def condition(char: str): + def condition(char: str) -> bool: return not char.isalnum() and char != "_" start = 0