Skip to content

Commit 66d2638

Browse files
Upgrade to modern Python syntax (#1956)
* Upgrade to modern Python syntax * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 02446b3 commit 66d2638

Some content is hidden

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

56 files changed

+179
-181
lines changed

docs/source/manim_directive.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def run(self):
202202
".. code-block:: python",
203203
"",
204204
" from manim import *\n",
205-
*[" " + line for line in self.content],
205+
*(" " + line for line in self.content),
206206
]
207207
source_block = "\n".join(source_block)
208208

@@ -286,7 +286,7 @@ def _write_rendering_stats(scene_name, run_time, file_name):
286286
with open(rendering_times_file_path, "a") as file:
287287
csv.writer(file).writerow(
288288
[
289-
re.sub("^(reference\/)|(manim\.)", "", file_name),
289+
re.sub(r"^(reference\/)|(manim\.)", "", file_name),
290290
scene_name,
291291
"%.3f" % run_time,
292292
]
@@ -302,15 +302,15 @@ def _log_rendering_times(*args):
302302

303303
print("\nRendering Summary\n-----------------\n")
304304

305-
max_file_length = max([len(row[0]) for row in data])
305+
max_file_length = max(len(row[0]) for row in data)
306306
for key, group in it.groupby(data, key=lambda row: row[0]):
307307
key = key.ljust(max_file_length + 1, ".")
308308
group = list(group)
309309
if len(group) == 1:
310310
row = group[0]
311311
print(f"{key}{row[2].rjust(7, '.')}s {row[1]}")
312312
continue
313-
time_sum = sum([float(row[2]) for row in group])
313+
time_sum = sum(float(row[2]) for row in group)
314314
print(
315315
f"{key}{f'{time_sum:.3f}'.rjust(7, '.')}s => {len(group)} EXAMPLES"
316316
)

example_scenes/basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def construct(self):
2929
transform_title.to_corner(UP + LEFT)
3030
self.play(
3131
Transform(title, transform_title),
32-
LaggedStart(*[FadeOut(obj, shift=DOWN) for obj in basel]),
32+
LaggedStart(*(FadeOut(obj, shift=DOWN) for obj in basel)),
3333
)
3434
self.wait()
3535

manim/animation/animation.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,9 @@ def __new__(
106106
if func is not None:
107107
anim = func(mobject, *args, **kwargs)
108108
logger.debug(
109-
(
110-
f"The {cls.__name__} animation has been is overridden for "
111-
f"{type(mobject).__name__} mobjects. use_override = False can "
112-
f" be used as keyword argument to prevent animation overriding."
113-
)
109+
f"The {cls.__name__} animation has been is overridden for "
110+
f"{type(mobject).__name__} mobjects. use_override = False can "
111+
f" be used as keyword argument to prevent animation overriding."
114112
)
115113
return anim
116114
return super().__new__(cls)
@@ -224,7 +222,7 @@ def get_all_mobjects(self) -> Sequence[Mobject]:
224222

225223
def get_all_families_zipped(self) -> Iterable[Tuple]:
226224
return zip(
227-
*[mob.family_members_with_points() for mob in self.get_all_mobjects()]
225+
*(mob.family_members_with_points() for mob in self.get_all_mobjects())
228226
)
229227

230228
def update_mobjects(self, dt: float) -> None:

manim/animation/creation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,12 +500,12 @@ def __init__(
500500
self.time_per_char = time_per_char
501501
tpc = self.time_per_char
502502
anims = it.chain(
503-
*[
503+
*(
504504
[
505505
ShowIncreasingSubsets(word, run_time=tpc * len(word)),
506506
Animation(word, run_time=0.005 * len(word) ** 1.5),
507507
]
508508
for word in text_mobject
509-
]
509+
)
510510
)
511511
super().__init__(*anims, **kwargs)

manim/animation/indication.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def __init__(self, vmobject, n_segments=10, time_width=0.1, remover=True, **kwar
327327
max_time_width = kwargs.pop("time_width", self.time_width)
328328
AnimationGroup.__init__(
329329
self,
330-
*[
330+
*(
331331
ShowPassingFlash(
332332
vmobject.deepcopy().set_stroke(width=stroke_width),
333333
time_width=time_width,
@@ -337,7 +337,7 @@ def __init__(self, vmobject, n_segments=10, time_width=0.1, remover=True, **kwar
337337
np.linspace(0, max_stroke_width, self.n_segments),
338338
np.linspace(max_time_width, 0, self.n_segments),
339339
)
340-
],
340+
),
341341
)
342342

343343

manim/animation/transform.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def get_all_families_zipped(self) -> Iterable[tuple]: # more precise typing?
136136
self.starting_mobject,
137137
self.target_copy,
138138
]
139-
return zip(*[mob.family_members_with_points() for mob in mobs])
139+
return zip(*(mob.family_members_with_points() for mob in mobs))
140140

141141
def interpolate_submobject(
142142
self,

manim/camera/camera.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ def set_cairo_context_color(self, ctx, rgbas, vmobject):
678678
else:
679679
points = vmobject.get_gradient_start_and_end_points()
680680
points = self.transform_points_pre_display(vmobject, points)
681-
pat = cairo.LinearGradient(*it.chain(*[point[:2] for point in points]))
681+
pat = cairo.LinearGradient(*it.chain(*(point[:2] for point in points)))
682682
step = 1.0 / (len(rgbas) - 1)
683683
offsets = np.arange(0, 1 + step, step)
684684
for rgba, offset in zip(rgbas, offsets):

manim/grpc/gen/frameserver_pb2.py

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manim/grpc/gen/frameserver_pb2_grpc.py

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manim/grpc/gen/renderserver_pb2.py

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)