Skip to content

Commit 24025b6

Browse files
pre-commit change to ruff (#3779)
* pre-commit change to ruff * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * fixes * astral-sh ruff bump --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 21eb0b7 commit 24025b6

File tree

22 files changed

+113
-88
lines changed

22 files changed

+113
-88
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,11 @@ repos:
3434
hooks:
3535
- id: python-check-blanket-noqa
3636
name: Precision flake ignores
37-
- repo: https://github.com/psf/black
38-
rev: 24.4.2
37+
- repo: https://github.com/astral-sh/ruff-pre-commit
38+
rev: v0.4.4
3939
hooks:
40-
- id: black
41-
- repo: https://github.com/asottile/blacken-docs
42-
rev: 1.16.0
43-
hooks:
44-
- id: blacken-docs
45-
additional_dependencies: [black==24.4.0]
46-
exclude: ^\.github/
40+
- id: ruff-format
41+
types: [python]
4742
- repo: https://github.com/PyCQA/flake8
4843
rev: 7.0.0
4944
hooks:

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

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/mobject/geometry/tips.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ class ArrowTip(VMobject, metaclass=ConvertToOpenGL):
6060
... RegularPolygon.__init__(self, n=5, **kwargs)
6161
... self.width = length
6262
... self.stretch_to_fit_height(length)
63-
>>> arr = Arrow(np.array([-2, -2, 0]), np.array([2, 2, 0]),
64-
... tip_shape=MyCustomArrowTip)
63+
>>> arr = Arrow(
64+
... np.array([-2, -2, 0]), np.array([2, 2, 0]), tip_shape=MyCustomArrowTip
65+
... )
6566
>>> isinstance(arr.tip, RegularPolygon)
6667
True
6768
>>> from manim import Scene, Create

manim/mobject/graph.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,8 @@ def expand_vertex(self, g, vertex_id: str, depth: int):
15131513
*new_edges,
15141514
vertex_config=self.VERTEX_CONF,
15151515
positions={
1516-
k: g.vertices[vertex_id].get_center() + 0.1 * DOWN for k in new_vertices
1516+
k: g.vertices[vertex_id].get_center() + 0.1 * DOWN
1517+
for k in new_vertices
15171518
},
15181519
)
15191520
if depth < self.DEPTH:

manim/mobject/graphing/coordinate_systems.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,9 @@ def add_coordinates(
394394
ax = ThreeDAxes()
395395
x_labels = range(-4, 5)
396396
z_labels = range(-4, 4, 2)
397-
ax.add_coordinates(x_labels, None, z_labels) # default y labels, custom x & z labels
397+
ax.add_coordinates(
398+
x_labels, None, z_labels
399+
) # default y labels, custom x & z labels
398400
ax.add_coordinates(x_labels) # only x labels
399401
400402
You can also specifically control the position and value of the labels using a dict.
@@ -405,7 +407,15 @@ def add_coordinates(
405407
x_pos = [x for x in range(1, 8)]
406408
407409
# strings are automatically converted into a Tex mobject.
408-
x_vals = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
410+
x_vals = [
411+
"Monday",
412+
"Tuesday",
413+
"Wednesday",
414+
"Thursday",
415+
"Friday",
416+
"Saturday",
417+
"Sunday",
418+
]
409419
x_dict = dict(zip(x_pos, x_vals))
410420
ax.add_coordinates(x_dict)
411421
"""

manim/mobject/graphing/number_line.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def number_to_point(self, number: float | np.ndarray) -> np.ndarray:
364364
array([0., 0., 0.])
365365
>>> number_line.number_to_point(1)
366366
array([1., 0., 0.])
367-
>>> number_line.number_to_point([1,2,3])
367+
>>> number_line.number_to_point([1, 2, 3])
368368
array([[1., 0., 0.],
369369
[2., 0., 0.],
370370
[3., 0., 0.]])
@@ -396,11 +396,11 @@ def point_to_number(self, point: Sequence[float]) -> float:
396396
397397
>>> from manim import NumberLine
398398
>>> number_line = NumberLine()
399-
>>> number_line.point_to_number((0,0,0))
399+
>>> number_line.point_to_number((0, 0, 0))
400400
0.0
401-
>>> number_line.point_to_number((1,0,0))
401+
>>> number_line.point_to_number((1, 0, 0))
402402
1.0
403-
>>> number_line.point_to_number([[0.5,0,0],[1,0,0],[1.5,0,0]])
403+
>>> number_line.point_to_number([[0.5, 0, 0], [1, 0, 0], [1.5, 0, 0]])
404404
array([0.5, 1. , 1.5])
405405
406406
"""

manim/mobject/mobject.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2064,7 +2064,7 @@ def get_critical_point(self, direction: Vector3D) -> Point3D:
20642064
20652065
::
20662066
2067-
sample = Arc(start_angle=PI/7, angle = PI/5)
2067+
sample = Arc(start_angle=PI / 7, angle=PI / 5)
20682068
20692069
# These are all equivalent
20702070
max_y_1 = sample.get_top()[1]

manim/mobject/text/text_mobject.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,17 @@ class Paragraph(VGroup):
135135
--------
136136
Normal usage::
137137
138-
paragraph = Paragraph('this is a awesome', 'paragraph',
139-
'With \nNewlines', '\tWith Tabs',
140-
' With Spaces', 'With Alignments',
141-
'center', 'left', 'right')
138+
paragraph = Paragraph(
139+
"this is a awesome",
140+
"paragraph",
141+
"With \nNewlines",
142+
"\tWith Tabs",
143+
" With Spaces",
144+
"With Alignments",
145+
"center",
146+
"left",
147+
"right",
148+
)
142149
143150
Remove unwanted invisible characters::
144151
@@ -1305,15 +1312,13 @@ def add_line_to(end):
13051312
self.set_color_by_gradient(*self.gradient)
13061313
for col in colormap:
13071314
self.chars[
1308-
col["start"]
1309-
- col["start_offset"] : col["end"]
1315+
col["start"] - col["start_offset"] : col["end"]
13101316
- col["start_offset"]
13111317
- col["end_offset"]
13121318
].set_color(self._parse_color(col["color"]))
13131319
for grad in gradientmap:
13141320
self.chars[
1315-
grad["start"]
1316-
- grad["start_offset"] : grad["end"]
1321+
grad["start"] - grad["start_offset"] : grad["end"]
13171322
- grad["start_offset"]
13181323
- grad["end_offset"]
13191324
].set_color_by_gradient(

manim/mobject/types/vectorized_mobject.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,19 +1926,21 @@ class VGroup(VMobject, metaclass=ConvertToOpenGL):
19261926
>>> triangle, square = Triangle(), Square()
19271927
>>> vg.add(triangle)
19281928
VGroup(Triangle)
1929-
>>> vg + square # a new VGroup is constructed
1929+
>>> vg + square # a new VGroup is constructed
19301930
VGroup(Triangle, Square)
1931-
>>> vg # not modified
1931+
>>> vg # not modified
19321932
VGroup(Triangle)
1933-
>>> vg += square; vg # modifies vg
1933+
>>> vg += square
1934+
>>> vg # modifies vg
19341935
VGroup(Triangle, Square)
19351936
>>> vg.remove(triangle)
19361937
VGroup(Square)
1937-
>>> vg - square; # a new VGroup is constructed
1938+
>>> vg - square # a new VGroup is constructed
19381939
VGroup()
1939-
>>> vg # not modified
1940+
>>> vg # not modified
19401941
VGroup(Square)
1941-
>>> vg -= square; vg # modifies vg
1942+
>>> vg -= square
1943+
>>> vg # modifies vg
19421944
VGroup()
19431945
19441946
.. manim:: ArcShapeIris
@@ -2200,7 +2202,7 @@ def add(
22002202
Normal usage::
22012203
22022204
square_obj = Square()
2203-
my_dict.add([('s', square_obj)])
2205+
my_dict.add([("s", square_obj)])
22042206
"""
22052207
for key, value in dict(mapping_or_iterable).items():
22062208
self.add_key_value_pair(key, value)
@@ -2227,7 +2229,7 @@ def remove(self, key: Hashable) -> Self:
22272229
--------
22282230
Normal usage::
22292231
2230-
my_dict.remove('square')
2232+
my_dict.remove("square")
22312233
"""
22322234
if key not in self.submob_dict:
22332235
raise KeyError("The given key '%s' is not present in the VDict" % str(key))
@@ -2252,7 +2254,7 @@ def __getitem__(self, key: Hashable):
22522254
--------
22532255
Normal usage::
22542256
2255-
self.play(Create(my_dict['s']))
2257+
self.play(Create(my_dict["s"]))
22562258
"""
22572259
submob = self.submob_dict[key]
22582260
return submob
@@ -2276,7 +2278,7 @@ def __setitem__(self, key: Hashable, value: VMobject) -> None:
22762278
Normal usage::
22772279
22782280
square_obj = Square()
2279-
my_dict['sq'] = square_obj
2281+
my_dict["sq"] = square_obj
22802282
"""
22812283
if key in self.submob_dict:
22822284
self.remove(key)
@@ -2381,7 +2383,7 @@ def add_key_value_pair(self, key: Hashable, value: VMobject) -> None:
23812383
Normal usage::
23822384
23832385
square_obj = Square()
2384-
self.add_key_value_pair('s', square_obj)
2386+
self.add_key_value_pair("s", square_obj)
23852387
23862388
"""
23872389
self._assert_valid_submobjects([value])

manim/scene/scene.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,8 +1555,7 @@ def construct(self):
15551555
15561556
# second option: within the call to Scene.play
15571557
self.play(
1558-
Transform(square, circle),
1559-
subcaption="The square transforms."
1558+
Transform(square, circle), subcaption="The square transforms."
15601559
)
15611560
15621561
"""

manim/scene/scene_file_writer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,6 @@ def combine_to_movie(self):
715715
av.open(movie_file_path) as video_input,
716716
av.open(sound_file_path) as audio_input,
717717
):
718-
719718
video_stream = video_input.streams.video[0]
720719
audio_stream = audio_input.streams.audio[0]
721720
output_container = av.open(

manim/utils/color/X11.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
2323
.. automanimcolormodule:: manim.utils.color.X11
2424
"""
25+
2526
from .core import ManimColor
2627

2728
ALICEBLUE = ManimColor("#F0F8FF")

manim/utils/color/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ def __init__(
147147
else:
148148
if length == 3:
149149
self._internal_value = ManimColor._internal_from_int_rgb(
150-
value, alpha # type: ignore
150+
value,
151+
alpha, # type: ignore
151152
)
152153
elif length == 4:
153154
self._internal_value = ManimColor._internal_from_int_rgba(value) # type: ignore

0 commit comments

Comments
 (0)