Skip to content

Commit 4b58092

Browse files
chore: use ruff + linting errors
1 parent b415604 commit 4b58092

File tree

76 files changed

+460
-375
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+460
-375
lines changed

.pre-commit-config.yaml

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,52 +12,24 @@ repos:
1212
- id: end-of-file-fixer
1313
- id: check-toml
1414
name: Validate Poetry
15-
- repo: https://github.com/pycqa/isort
16-
rev: 5.13.2
17-
hooks:
18-
- id: isort
19-
name: isort (python)
20-
- id: isort
21-
name: isort (cython)
22-
types: [cython]
23-
- id: isort
24-
name: isort (pyi)
25-
types: [pyi]
26-
- repo: https://github.com/asottile/pyupgrade
27-
rev: v3.15.2
28-
hooks:
29-
- id: pyupgrade
30-
name: Update code to new python versions
31-
args: [--py39-plus]
3215
- repo: https://github.com/pre-commit/pygrep-hooks
3316
rev: v1.10.0
3417
hooks:
3518
- id: python-check-blanket-noqa
3619
name: Precision flake ignores
37-
- repo: https://github.com/psf/black
38-
rev: 24.4.2
39-
hooks:
40-
- id: black
4120
- repo: https://github.com/asottile/blacken-docs
4221
rev: 1.16.0
4322
hooks:
4423
- id: blacken-docs
4524
additional_dependencies: [black==24.4.0]
4625
exclude: ^\.github/
47-
- repo: https://github.com/PyCQA/flake8
48-
rev: 7.0.0
26+
- repo: https://github.com/astral-sh/ruff-pre-commit
27+
rev: v0.3.5
4928
hooks:
50-
- id: flake8
51-
additional_dependencies:
52-
[
53-
flake8-bugbear==21.4.3,
54-
flake8-builtins==1.5.3,
55-
flake8-comprehensions>=3.6.1,
56-
flake8-docstrings==1.6.0,
57-
flake8-pytest-style==1.5.0,
58-
flake8-rst-docstrings==0.2.3,
59-
flake8-simplify==0.14.1,
60-
]
29+
- id: ruff
30+
args: [ "--fix", "--exit-non-zero-on-fix"]
31+
name: ruff lint
32+
- id: ruff-format
6133
- repo: https://github.com/pre-commit/mirrors-mypy
6234
rev: v1.10.0
6335
hooks:
@@ -77,4 +49,6 @@ repos:
7749
hooks:
7850
- id: codespell
7951
files: ^.*\.(py|md|rst)$
80-
args: ["-L", "medias,nam"]
52+
# for pyproject configuration (remove python>=3.11)
53+
additional_dependencies:
54+
- tomli

example_scenes/basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def construct(self):
153153
],
154154
color=PURPLE_B,
155155
fill_opacity=1,
156-
stroke_width=0
156+
stroke_width=0,
157157
).shift(UP + 2 * RIGHT)
158158
shapes = VGroup(triangle, square, circle, pentagon, pi)
159159
self.play(SpiralIn(shapes, fade_in_fraction=0.9))

example_scenes/opengl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from pathlib import Path
22

3-
import manim.utils.opengl as opengl
43
from manim import *
54
from manim.opengl import * # type: ignore
5+
from manim.utils import opengl
66

77
# Copied from https://3b1b.github.io/manim/getting_started/example_scenes.html#surfaceexample.
88
# Lines that do not yet work with the Community Version are commented.

manim/_config/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ def tempconfig(temp: ManimConfig | dict[str, Any]) -> Generator[None, None, None
6868
8.0
6969
>>> with tempconfig({"frame_height": 100.0}):
7070
... print(config["frame_height"])
71-
...
7271
100.0
7372
>>> config["frame_height"]
7473
8.0

manim/_config/cli_colors.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,18 @@ def parse_cli_ctx(parser: configparser.SectionProxy) -> Context:
3535
theme = parser["theme"] if parser["theme"] else None
3636
if theme is None:
3737
formatter = HelpFormatter.settings(
38-
theme=HelpTheme(**theme_settings), **formatter_settings # type: ignore[arg-type]
38+
theme=HelpTheme(**theme_settings),
39+
**formatter_settings, # type: ignore[arg-type]
3940
)
4041
elif theme.lower() == "dark":
4142
formatter = HelpFormatter.settings(
42-
theme=HelpTheme.dark().with_(**theme_settings), **formatter_settings # type: ignore[arg-type]
43+
theme=HelpTheme.dark().with_(**theme_settings),
44+
**formatter_settings, # type: ignore[arg-type]
4345
)
4446
elif theme.lower() == "light":
4547
formatter = HelpFormatter.settings(
46-
theme=HelpTheme.light().with_(**theme_settings), **formatter_settings # type: ignore[arg-type]
48+
theme=HelpTheme.light().with_(**theme_settings),
49+
**formatter_settings, # type: ignore[arg-type]
4750
)
4851

4952
return Context.settings(

manim/_config/utils.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -641,14 +641,14 @@ def digest_parser(self, parser: configparser.ConfigParser) -> Self:
641641
gui_location = tuple(
642642
map(int, re.split(r"[;,\-]", parser["CLI"]["gui_location"])),
643643
)
644-
setattr(self, "gui_location", gui_location)
644+
self.gui_location = gui_location
645645

646646
window_size = parser["CLI"][
647647
"window_size"
648648
] # if not "default", get a tuple of the position
649649
if window_size != "default":
650650
window_size = tuple(map(int, re.split(r"[;,\-]", window_size)))
651-
setattr(self, "window_size", window_size)
651+
self.window_size = window_size
652652

653653
# plugins
654654
plugins = parser["CLI"].get("plugins", fallback="", raw=True)
@@ -672,7 +672,7 @@ def digest_parser(self, parser: configparser.ConfigParser) -> Self:
672672

673673
val = parser["CLI"].get("progress_bar")
674674
if val:
675-
setattr(self, "progress_bar", val)
675+
self.progress_bar = val
676676

677677
val = parser["ffmpeg"].get("loglevel")
678678
if val:
@@ -682,11 +682,11 @@ def digest_parser(self, parser: configparser.ConfigParser) -> Self:
682682
val = parser["jupyter"].getboolean("media_embed")
683683
except ValueError:
684684
val = None
685-
setattr(self, "media_embed", val)
685+
self.media_embed = val
686686

687687
val = parser["jupyter"].get("media_width")
688688
if val:
689-
setattr(self, "media_width", val)
689+
self.media_width = val
690690

691691
val = parser["CLI"].get("quality", fallback="", raw=True)
692692
if val:
@@ -837,15 +837,12 @@ def digest_args(self, args: argparse.Namespace) -> Self:
837837
if args.tex_template:
838838
self.tex_template = TexTemplate.from_file(args.tex_template)
839839

840-
if (
841-
self.renderer == RendererType.OPENGL
842-
and getattr(args, "write_to_movie") is None
843-
):
840+
if self.renderer == RendererType.OPENGL and args.write_to_movie is None:
844841
# --write_to_movie was not passed on the command line, so don't generate video.
845842
self["write_to_movie"] = False
846843

847844
# Handle --gui_location flag.
848-
if getattr(args, "gui_location") is not None:
845+
if args.gui_location is not None:
849846
self.gui_location = args.gui_location
850847

851848
return self

manim/animation/animation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def _typecheck_input(self, mobject: Mobject | None) -> None:
180180
def __str__(self) -> str:
181181
if self.name:
182182
return self.name
183-
return f"{self.__class__.__name__}({str(self.mobject)})"
183+
return f"{self.__class__.__name__}({self.mobject!s})"
184184

185185
def __repr__(self) -> str:
186186
return str(self)

manim/animation/indication.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ def construct(self):
6363
from ..mobject.types.vectorized_mobject import VGroup, VMobject
6464
from ..utils.bezier import interpolate, inverse_interpolate
6565
from ..utils.color import GREY, YELLOW, ParsableManimColor
66-
from ..utils.deprecation import deprecated
6766
from ..utils.rate_functions import smooth, there_and_back, wiggle
6867
from ..utils.space_ops import normalize
6968

manim/cli/checkhealth/checks.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55

66
import os
77
import shutil
8-
import subprocess
98
from typing import Callable
109

11-
from ..._config import config
12-
1310
__all__ = ["HEALTH_CHECKS"]
1411

1512
HEALTH_CHECKS = []

manim/mobject/geometry/arc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def construct(self):
6363
)
6464

6565
if TYPE_CHECKING:
66-
import manim.mobject.geometry.tips as tips
66+
from manim.mobject.geometry import tips
6767
from manim.mobject.mobject import Mobject
6868
from manim.mobject.text.tex_mobject import SingleStringMathTex, Tex
6969
from manim.mobject.text.text_mobject import Text

0 commit comments

Comments
 (0)