Bump Python target versions of both mypy and ruff

Merging #4520 - all CI checks passing and approved by JasonGrace2282
This commit is contained in:
Benjamin Hackl 2026-01-13 01:13:21 +01:00 committed by GitHub
commit 4bc77b3a00
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
65 changed files with 321 additions and 204 deletions

View file

@ -33,8 +33,7 @@ from manim.utils.tex import TexTemplate
if TYPE_CHECKING:
from enum import EnumMeta
from typing_extensions import Self
from typing import Self
from manim.typing import StrPath, Vector3D

View file

@ -17,9 +17,7 @@ __all__ = ["Animation", "Wait", "Add", "override_animation"]
from collections.abc import Callable, Iterable, Sequence
from copy import deepcopy
from functools import partialmethod
from typing import TYPE_CHECKING, Any
from typing_extensions import Self
from typing import TYPE_CHECKING, Any, Self
if TYPE_CHECKING:
from manim.scene.scene import Scene
@ -280,9 +278,12 @@ class Animation:
def get_all_families_zipped(self) -> Iterable[tuple]:
if config["renderer"] == RendererType.OPENGL:
return zip(*(mob.get_family() for mob in self.get_all_mobjects()))
return zip(
*(mob.get_family() for mob in self.get_all_mobjects()), strict=False
)
return zip(
*(mob.family_members_with_points() for mob in self.get_all_mobjects())
*(mob.family_members_with_points() for mob in self.get_all_mobjects()),
strict=False,
)
def update_mobjects(self, dt: float) -> None:

View file

@ -5,9 +5,7 @@ from __future__ import annotations
__all__ = ["AnimatedBoundary", "TracedPath"]
from collections.abc import Callable, Sequence
from typing import Any
from typing_extensions import Self
from typing import Any, Self
from manim.mobject.mobject import Mobject
from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL
@ -99,7 +97,7 @@ class AnimatedBoundary(VGroup):
) -> Self:
family1 = mob1.family_members_with_points()
family2 = mob2.family_members_with_points()
for sm1, sm2 in zip(family1, family2):
for sm1, sm2 in zip(family1, family2, strict=False):
sm1.pointwise_become_partial(sm2, a, b)
return self

View file

@ -185,7 +185,9 @@ class AnimationGroup(Animation):
else:
sub_alphas[(sub_alphas > 1) | with_zero_run_time] = 1
for anim_to_update, sub_alpha in zip(to_update["anim"], sub_alphas):
for anim_to_update, sub_alpha in zip(
to_update["anim"], sub_alphas, strict=False
):
anim_to_update.interpolate(sub_alpha)
self.anim_group_time = anim_group_time

View file

@ -472,7 +472,7 @@ class SpiralIn(Animation):
def interpolate_mobject(self, alpha: float) -> None:
alpha = self.rate_func(alpha)
for original_shape, shape in zip(self.shapes, self.mobject):
for original_shape, shape in zip(self.shapes, self.mobject, strict=False):
shape.restore()
fill_opacity = original_shape.get_fill_opacity()
stroke_opacity = original_shape.get_stroke_opacity()

View file

@ -40,10 +40,9 @@ __all__ = [
]
from collections.abc import Iterable
from typing import Any
from typing import Any, Self
import numpy as np
from typing_extensions import Self
from manim.mobject.geometry.arc import Circle, Dot
from manim.mobject.geometry.line import Line
@ -350,6 +349,7 @@ class ShowPassingFlashWithThinningStrokeWidth(AnimationGroup):
for stroke_width, time_width in zip(
np.linspace(0, max_stroke_width, self.n_segments),
np.linspace(max_time_width, 0, self.n_segments),
strict=False,
)
),
)

View file

@ -10,7 +10,8 @@ __all__ = [
"MoveAlongPath",
]
from typing import TYPE_CHECKING, Any, Callable
from collections.abc import Callable
from typing import TYPE_CHECKING, Any
import numpy as np
@ -18,7 +19,7 @@ from ..animation.animation import Animation
from ..utils.rate_functions import linear
if TYPE_CHECKING:
from typing_extensions import Self
from typing import Self
from manim.mobject.types.vectorized_mobject import VMobject
from manim.typing import MappingFunction, Point3D

View file

@ -234,8 +234,8 @@ class Transform(Animation):
self.target_copy,
]
if config.renderer == RendererType.OPENGL:
return zip(*(mob.get_family() for mob in mobs))
return zip(*(mob.family_members_with_points() for mob in mobs))
return zip(*(mob.get_family() for mob in mobs), strict=False)
return zip(*(mob.family_members_with_points() for mob in mobs), strict=False)
def interpolate_submobject(
self,
@ -740,7 +740,7 @@ class CyclicReplace(Transform):
def create_target(self) -> Group:
target = self.group.copy()
cycled_targets = [target[-1], *target[:-1]]
for m1, m2 in zip(cycled_targets, self.group):
for m1, m2 in zip(cycled_targets, self.group, strict=False):
m1.move_to(m2)
return target
@ -928,5 +928,5 @@ class FadeTransformPieces(FadeTransform):
"""Replaces the source submobjects by the target submobjects and sets
the opacity to 0.
"""
for sm0, sm1 in zip(source.get_family(), target.get_family()):
for sm0, sm1 in zip(source.get_family(), target.get_family(), strict=False):
super().ghost_to(sm0, sm1)

View file

@ -10,14 +10,13 @@ import operator as op
import pathlib
from collections.abc import Callable, Iterable
from functools import reduce
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, Self
import cairo
import numpy as np
import numpy.typing as npt
from PIL import Image
from scipy.spatial.distance import pdist
from typing_extensions import Self
from manim.typing import (
FloatRGBA_Array,
@ -759,7 +758,7 @@ class Camera:
pat = cairo.LinearGradient(*it.chain(*(point[:2] for point in points)))
step = 1.0 / (len(rgbas) - 1)
offsets = np.arange(0, 1 + step, step)
for rgba, offset in zip(rgbas, offsets):
for rgba, offset in zip(rgbas, offsets, strict=False):
pat.add_color_stop_rgba(offset, *rgba[2::-1], rgba[3])
ctx.set_source(pat)
return self

View file

@ -6,9 +6,7 @@ __all__ = ["MultiCamera"]
from collections.abc import Iterable
from typing import Any
from typing_extensions import Self
from typing import Any, Self
from manim.mobject.mobject import Mobject
from manim.mobject.types.image_mobject import ImageMobjectFromCamera

View file

@ -45,10 +45,9 @@ __all__ = [
import itertools
import warnings
from typing import TYPE_CHECKING, Any, cast
from typing import TYPE_CHECKING, Any, Self, cast
import numpy as np
from typing_extensions import Self
from manim.constants import *
from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL
@ -1233,7 +1232,7 @@ class ArcPolygon(VMobject, metaclass=ConvertToOpenGL):
arcs = [
ArcBetweenPoints(*pair, **conf)
for (pair, conf) in zip(point_pairs, all_arc_configs)
for (pair, conf) in zip(point_pairs, all_arc_configs, strict=False)
]
super().__init__(**kwargs)

View file

@ -30,7 +30,7 @@ from manim.utils.color import WHITE
from manim.utils.space_ops import angle_of_vector, line_intersection, normalize
if TYPE_CHECKING:
from typing_extensions import Self, TypeAlias
from typing import Self, TypeAlias
from manim.typing import Point3D, Point3DLike, Vector2DLike, Vector3D, Vector3DLike
from manim.utils.color import ParsableManimColor

View file

@ -32,8 +32,9 @@ from manim.utils.qhull import QuickHull
from manim.utils.space_ops import angle_between_vectors, normalize, regular_vertices
if TYPE_CHECKING:
from typing import Self
import numpy.typing as npt
from typing_extensions import Self
from manim.typing import (
Point3D,
@ -150,7 +151,9 @@ class Polygram(VMobject, metaclass=ConvertToOpenGL):
# TODO: If any of the original vertex groups contained the starting vertex N
# times, then .get_vertex_groups() splits it into N vertex groups.
group = []
for start, end in zip(self.get_start_anchors(), self.get_end_anchors()):
for start, end in zip(
self.get_start_anchors(), self.get_end_anchors(), strict=False
):
group.append(start)
if self.consider_points_equals(end, group[0]):
@ -237,7 +240,7 @@ class Polygram(VMobject, metaclass=ConvertToOpenGL):
radius_list = radius * ceil(len(vertex_group) / len(radius))
for current_radius, (v1, v2, v3) in zip(
radius_list, adjacent_n_tuples(vertex_group, 3)
radius_list, adjacent_n_tuples(vertex_group, 3), strict=False
):
vect1 = v2 - v1
vect2 = v3 - v2
@ -549,7 +552,7 @@ class Star(Polygon):
)
vertices: list[npt.NDArray] = []
for pair in zip(outer_vertices, inner_vertices):
for pair in zip(outer_vertices, inner_vertices, strict=False):
vertices.extend(pair)
super().__init__(*vertices, **kwargs)

View file

@ -4,9 +4,7 @@ from __future__ import annotations
__all__ = ["SurroundingRectangle", "BackgroundRectangle", "Cross", "Underline"]
from typing import Any
from typing_extensions import Self
from typing import Any, Self
from manim import logger
from manim._config import config

View file

@ -16,7 +16,7 @@ import networkx as nx
import numpy as np
if TYPE_CHECKING:
from typing_extensions import TypeAlias
from typing import TypeAlias
from manim.scene.scene import Scene
from manim.typing import Point3D, Point3DLike

View file

@ -14,10 +14,9 @@ __all__ = [
import fractions as fr
import numbers
from collections.abc import Callable, Iterable, Sequence
from typing import TYPE_CHECKING, Any, TypeVar, overload
from typing import TYPE_CHECKING, Any, Self, TypeVar, overload
import numpy as np
from typing_extensions import Self
from manim import config
from manim.constants import *
@ -438,14 +437,20 @@ class CoordinateSystem:
if not axes_numbers:
axes_numbers = [None for _ in range(self.dimension)]
for axis, values in zip(self.axes, axes_numbers):
for axis, values in zip(self.axes, axes_numbers, strict=False):
if isinstance(values, dict):
axis.add_labels(values, **kwargs)
labels = axis.labels
elif values is None and axis.scaling.custom_labels:
tick_range = axis.get_tick_range()
axis.add_labels(
dict(zip(tick_range, axis.scaling.get_custom_labels(tick_range)))
dict(
zip(
tick_range,
axis.scaling.get_custom_labels(tick_range),
strict=False,
)
)
)
labels = axis.labels
else:
@ -1295,7 +1300,7 @@ class CoordinateSystem:
colors = color_gradient(color, len(x_range_array))
for x, color in zip(x_range_array, colors):
for x, color in zip(x_range_array, colors, strict=False):
if input_sample_type == "left":
sample_input = x
elif input_sample_type == "right":
@ -2031,7 +2036,9 @@ class Axes(VGroup, CoordinateSystem, metaclass=ConvertToOpenGL):
)
)
"""
for default_config, passed_config in zip(default_configs, passed_configs):
for default_config, passed_config in zip(
default_configs, passed_configs, strict=False
):
if passed_config is not None:
update_dict_recursively(default_config, passed_config)
@ -2161,7 +2168,7 @@ class Axes(VGroup, CoordinateSystem, metaclass=ConvertToOpenGL):
# Although "points" and "nums" are in plural, there might be a single point or number.
points = self.x_axis.number_to_point(coords[0])
other_axes = self.axes.submobjects[1:]
for axis, nums in zip(other_axes, coords[1:]):
for axis, nums in zip(other_axes, coords[1:], strict=False):
points += axis.number_to_point(nums) - origin
# Return points as is, except if coords originally looked like
@ -2355,7 +2362,7 @@ class Axes(VGroup, CoordinateSystem, metaclass=ConvertToOpenGL):
vertices = [
self.coords_to_point(x, y, z)
for x, y, z in zip(x_values, y_values, z_values)
for x, y, z in zip(x_values, y_values, z_values, strict=False)
]
graph.set_points_as_corners(vertices)
line_graph["line_graph"] = graph

View file

@ -17,9 +17,7 @@ from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL
from manim.mobject.types.vectorized_mobject import VMobject
if TYPE_CHECKING:
from typing import Any
from typing_extensions import Self
from typing import Any, Self
from manim.typing import Point3D, Point3DLike
from manim.utils.color import ParsableManimColor
@ -159,7 +157,7 @@ class ParametricFunction(VMobject, metaclass=ConvertToOpenGL):
else:
boundary_times = [self.t_min, self.t_max]
for t1, t2 in zip(boundary_times[0::2], boundary_times[1::2]):
for t1, t2 in zip(boundary_times[0::2], boundary_times[1::2], strict=False):
t_range = np.array(
[
*self.scaling.function(np.arange(t1, t2, self.t_step)),

View file

@ -12,9 +12,7 @@ from collections.abc import Callable, Iterable, Sequence
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from typing import Any
from typing_extensions import Self
from typing import Any, Self
from manim.mobject.geometry.tips import ArrowTip
from manim.typing import Point3D, Point3DLike, Vector3D
@ -264,6 +262,7 @@ class NumberLine(Line):
zip(
tick_range,
custom_labels,
strict=False,
)
),
)

View file

@ -107,7 +107,7 @@ class SampleSpace(Rectangle):
last_point = self.get_edge_center(-vect)
parts = VGroup()
for factor, color in zip(p_list_complete, colors_in_gradient):
for factor, color in zip(p_list_complete, colors_in_gradient, strict=False):
part = SampleSpace()
part.set_fill(color, 1)
part.replace(self, stretch=True)
@ -151,7 +151,7 @@ class SampleSpace(Rectangle):
) -> VGroup:
label_mobs = VGroup()
braces = VGroup()
for label, part in zip(labels, parts):
for label, part in zip(labels, parts, strict=False):
brace = Brace(part, direction, min_num_quads=min_num_quads, buff=buff)
if isinstance(label, (VMobject, OpenGLVMobject)):
label_mob = label
@ -367,7 +367,9 @@ class BarChart(Axes):
labels = VGroup()
for i, (value, bar_name) in enumerate(zip(val_range, self.bar_names)):
for i, (value, bar_name) in enumerate(
zip(val_range, self.bar_names, strict=False)
):
# to accommodate negative bars, the label may need to be
# below or above the x_axis depending on the value of the bar
direction = UP if self.values[i] < 0 else DOWN
@ -463,7 +465,7 @@ class BarChart(Axes):
self.add(chart, c_bar_lbls)
"""
bar_labels = VGroup()
for bar, value in zip(self.bars, self.values):
for bar, value in zip(self.bars, self.values, strict=False):
bar_lbl: MathTex = label_constructor(str(value))
if color is None:
@ -511,7 +513,7 @@ class BarChart(Axes):
chart.change_bar_values(list(reversed(values)))
self.add(chart.get_bar_labels(font_size=24))
"""
for i, (bar, value) in enumerate(zip(self.bars, values)):
for i, (bar, value) in enumerate(zip(self.bars, values, strict=False)):
chart_val = self.values[i]
if chart_val > 0:

View file

@ -11,7 +11,7 @@ __all__ = ["LogBase", "LinearBase"]
from manim.mobject.text.numbers import Integer
if TYPE_CHECKING:
from typing import Callable
from collections.abc import Callable
from manim.mobject.types.vectorized_mobject import VMobject

View file

@ -41,10 +41,9 @@ __all__ = [
import itertools as it
from collections.abc import Callable, Iterable, Sequence
from typing import Any
from typing import Any, Self
import numpy as np
from typing_extensions import Self
from manim.mobject.mobject import Mobject
from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL
@ -333,7 +332,7 @@ class Matrix(VMobject, metaclass=ConvertToOpenGL):
self.add(m0)
"""
columns = self.get_columns()
for color, column in zip(colors, columns):
for color, column in zip(colors, columns, strict=False):
column.set_color(color)
return self
@ -385,7 +384,7 @@ class Matrix(VMobject, metaclass=ConvertToOpenGL):
self.add(m0)
"""
rows = self.get_rows()
for color, row in zip(colors, rows):
for color, row in zip(colors, rows, strict=False):
row.set_color(color)
return self

View file

@ -41,7 +41,7 @@ from ..utils.paths import straight_path
from ..utils.space_ops import angle_between_vectors, normalize, rotation_matrix
if TYPE_CHECKING:
from typing_extensions import Self, TypeAlias
from typing import Self, TypeAlias
from manim.typing import (
FunctionOverride,
@ -2016,7 +2016,7 @@ class Mobject:
mobs = self.family_members_with_points()
new_colors = color_gradient(colors, len(mobs))
for mob, color in zip(mobs, new_colors):
for mob, color in zip(mobs, new_colors, strict=False):
mob.set_color(color, family=False)
return self
@ -2309,7 +2309,7 @@ class Mobject:
return Group(
*(
template.copy().pointwise_become_partial(self, a1, a2)
for a1, a2 in zip(alphas[:-1], alphas[1:])
for a1, a2 in zip(alphas[:-1], alphas[1:], strict=False)
)
)
@ -2502,7 +2502,7 @@ class Mobject:
x = VGroup(s1, s2, s3, s4).set_x(0).arrange(buff=1.0)
self.add(x)
"""
for m1, m2 in zip(self.submobjects, self.submobjects[1:]):
for m1, m2 in zip(self.submobjects, self.submobjects[1:], strict=False):
m2.next_to(m1, direction, buff, **kwargs)
if center:
self.center()
@ -2887,7 +2887,7 @@ class Mobject:
if not skip_point_alignment:
self.align_points(mobject)
# Recurse
for m1, m2 in zip(self.submobjects, mobject.submobjects):
for m1, m2 in zip(self.submobjects, mobject.submobjects, strict=False):
m1.align_data(m2)
def get_point_mobject(self, center=None):
@ -2957,7 +2957,7 @@ class Mobject:
repeat_indices = (np.arange(target) * curr) // target
split_factors = [sum(repeat_indices == i) for i in range(curr)]
new_submobs = []
for submob, sf in zip(self.submobjects, split_factors):
for submob, sf in zip(self.submobjects, split_factors, strict=False):
new_submobs.append(submob)
new_submobs.extend(submob.copy().fade(1) for _ in range(1, sf))
self.submobjects = new_submobs
@ -3169,7 +3169,7 @@ class Mobject:
mobject.move_to(self.get_center())
self.align_data(mobject, skip_point_alignment=True)
for sm1, sm2 in zip(self.get_family(), mobject.get_family()):
for sm1, sm2 in zip(self.get_family(), mobject.get_family(), strict=False):
sm1.points = np.array(sm2.points)
sm1.interpolate_color(sm1, sm2, 1)
return self
@ -3191,7 +3191,7 @@ class Mobject:
self.play(circ.animate.match_points(square))
self.wait(0.5)
"""
for sm1, sm2 in zip(self.get_family(), mobject.get_family()):
for sm1, sm2 in zip(self.get_family(), mobject.get_family(), strict=False):
sm1.points = np.array(sm2.points)
return self

View file

@ -2,10 +2,9 @@ from __future__ import annotations
__all__ = ["TrueDot", "DotCloud"]
from typing import Any
from typing import Any, Self
import numpy as np
from typing_extensions import Self
from manim.constants import ORIGIN, RIGHT, UP
from manim.mobject.opengl.opengl_point_cloud_mobject import OpenGLPMobject

View file

@ -1,9 +1,8 @@
from __future__ import annotations
from typing import Any, cast
from typing import Any, Self, cast
import numpy as np
from typing_extensions import Self
from manim.constants import *
from manim.mobject.mobject import Mobject

View file

@ -9,16 +9,23 @@ import types
from collections.abc import Callable, Iterable, Iterator, Sequence
from functools import partialmethod, wraps
from math import ceil
from typing import TYPE_CHECKING, Any, ClassVar, Protocol, TypeVar, cast
from typing import (
TYPE_CHECKING,
Any,
ClassVar,
Never,
Protocol,
Self,
TypeAlias,
TypeVar,
cast,
overload,
)
import moderngl
import numpy as np
import numpy.typing as npt
from typing_extensions import (
Never,
Self,
TypeAlias,
overload,
override,
)
@ -1048,7 +1055,7 @@ class OpenGLMobject:
x = OpenGLVGroup(s1, s2, s3, s4).set_x(0).arrange(buff=1.0)
self.add(x)
"""
for m1, m2 in zip(self.submobjects, self.submobjects[1:]):
for m1, m2 in zip(self.submobjects, self.submobjects[1:], strict=False):
m2.next_to(m1, direction, **kwargs)
if center:
self.center()
@ -2183,7 +2190,7 @@ class OpenGLMobject:
# Color and opacity
if color is not None and opacity is not None:
rgbas: FloatRGBA_Array = np.array(
[[*rgb, o] for rgb, o in zip(*make_even(rgbs, opacities))]
[[*rgb, o] for rgb, o in zip(*make_even(rgbs, opacities), strict=False)]
)
for mob in self.get_family(recurse):
mob.data[name] = rgbas.copy()
@ -2259,7 +2266,7 @@ class OpenGLMobject:
mobs = self.submobjects
new_colors = color_gradient(colors, len(mobs))
for mob, color in zip(mobs, new_colors):
for mob, color in zip(mobs, new_colors, strict=False):
mob.set_color(color)
return self
@ -2474,7 +2481,7 @@ class OpenGLMobject:
return OpenGLGroup(
*(
template.copy().pointwise_become_partial(self, a1, a2)
for a1, a2 in zip(alphas[:-1], alphas[1:])
for a1, a2 in zip(alphas[:-1], alphas[1:], strict=False)
)
)
@ -2575,7 +2582,7 @@ class OpenGLMobject:
def align_data(self, mobject: OpenGLMobject) -> Self:
# In case any data arrays get resized when aligned to shader data
# self.refresh_shader_data()
for mob1, mob2 in zip(self.get_family(), mobject.get_family()):
for mob1, mob2 in zip(self.get_family(), mobject.get_family(), strict=False):
# Separate out how points are treated so that subclasses
# can handle that case differently if they choose
mob1.align_points(mob2)
@ -2605,7 +2612,7 @@ class OpenGLMobject:
mob1.add_n_more_submobjects(max(0, n2 - n1))
mob2.add_n_more_submobjects(max(0, n1 - n2))
# Recurse
for sm1, sm2 in zip(mob1.submobjects, mob2.submobjects):
for sm1, sm2 in zip(mob1.submobjects, mob2.submobjects, strict=False):
sm1.align_family(sm2)
return self
@ -2631,7 +2638,7 @@ class OpenGLMobject:
repeat_indices = (np.arange(target) * curr) // target
split_factors = [(repeat_indices == i).sum() for i in range(curr)]
new_submobs = []
for submob, sf in zip(self.submobjects, split_factors):
for submob, sf in zip(self.submobjects, split_factors, strict=False):
new_submobs.append(submob)
for _ in range(1, sf):
new_submob = submob.copy()
@ -2773,7 +2780,7 @@ class OpenGLMobject:
mobject.move_to(self.get_center())
self.align_family(mobject)
for sm1, sm2 in zip(self.get_family(), mobject.get_family()):
for sm1, sm2 in zip(self.get_family(), mobject.get_family(), strict=False):
sm1.set_data(sm2.data)
sm1.set_uniforms(sm2.uniforms)
self.refresh_bounding_box(recurse_down=True)
@ -2802,6 +2809,7 @@ class OpenGLMobject:
self.get_family(),
mobject1.get_family(),
mobject2.get_family(),
strict=False,
):
keys = sm.data.keys() & sm1.data.keys() & sm2.data.keys()
sm.lock_data(

View file

@ -22,7 +22,7 @@ from manim.utils.config_ops import _Uniforms
from manim.utils.iterables import resize_with_interpolation
if TYPE_CHECKING:
from typing_extensions import Self
from typing import Self
from manim.typing import (
FloatRGBA_Array,

View file

@ -4,11 +4,10 @@ import itertools as it
import operator as op
from collections.abc import Callable, Iterable, Sequence
from functools import reduce, wraps
from typing import Any
from typing import Any, Self
import moderngl
import numpy as np
from typing_extensions import Self
from manim import config
from manim.constants import *
@ -351,7 +350,7 @@ class OpenGLVMobject(OpenGLMobject):
return self
elif len(submobs2) == 0:
submobs2 = [vmobject]
for sm1, sm2 in zip(*make_even(submobs1, submobs2)):
for sm1, sm2 in zip(*make_even(submobs1, submobs2), strict=False):
sm1.match_style(sm2)
return self
@ -581,7 +580,7 @@ class OpenGLVMobject(OpenGLMobject):
new_points.extend(
[
partial_bezier_points(tup, a1, a2)
for a1, a2 in zip(alphas, alphas[1:])
for a1, a2 in zip(alphas, alphas[1:], strict=False)
],
)
else:
@ -770,7 +769,7 @@ class OpenGLVMobject(OpenGLMobject):
split_indices = [0, *split_indices, len(points)]
return [
points[i1:i2]
for i1, i2 in zip(split_indices, split_indices[1:])
for i1, i2 in zip(split_indices, split_indices[1:], strict=False)
if (i2 - i1) >= nppc
]
@ -1094,7 +1093,7 @@ class OpenGLVMobject(OpenGLMobject):
s = self.get_start_anchors()
e = self.get_end_anchors()
return list(it.chain.from_iterable(zip(s, e)))
return list(it.chain.from_iterable(zip(s, e, strict=False)))
def get_points_without_null_curves(self, atol=1e-9):
nppc = self.n_points_per_curve

View file

@ -4,11 +4,10 @@ from __future__ import annotations
__all__ = ["Brace", "BraceLabel", "ArcBrace", "BraceText", "BraceBetweenPoints"]
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, Self
import numpy as np
import svgelements as se
from typing_extensions import Self
from manim._config import config
from manim.mobject.geometry.arc import Arc

View file

@ -526,7 +526,7 @@ class Table(VGroup):
self.add(table)
"""
columns = self.get_columns()
for color, column in zip(colors, columns):
for color, column in zip(colors, columns, strict=False):
column.set_color(color)
return self
@ -555,7 +555,7 @@ class Table(VGroup):
self.add(table)
"""
rows = self.get_rows()
for color, row in zip(colors, rows):
for color, row in zip(colors, rows, strict=False):
row.set_color(color)
return self

View file

@ -207,7 +207,7 @@ class Code(VMobject, metaclass=ConvertToOpenGL):
*code_lines,
**base_paragraph_config,
)
for line, color_range in zip(self.code_lines, color_ranges):
for line, color_range in zip(self.code_lines, color_ranges, strict=False):
for start, end, color in color_range:
line[start:end].set_color(color)

View file

@ -4,10 +4,9 @@ from __future__ import annotations
__all__ = ["DecimalNumber", "Integer", "Variable"]
from typing import Any
from typing import Any, Self
import numpy as np
from typing_extensions import Self
from manim import config
from manim.constants import *
@ -295,7 +294,7 @@ class DecimalNumber(VMobject, metaclass=ConvertToOpenGL):
self._set_submobjects_from_number(number)
self.font_size = old_font_size
self.move_to(move_to_point, self.edge_to_fix)
for sm1, sm2 in zip(self.submobjects, old_submobjects):
for sm1, sm2 in zip(self.submobjects, old_submobjects, strict=False):
sm1.match_style(sm2)
if config.renderer == RendererType.CAIRO:

View file

@ -29,9 +29,7 @@ import re
from collections.abc import Iterable, Sequence
from functools import reduce
from textwrap import dedent
from typing import Any
from typing_extensions import Self
from typing import Any, Self
from manim import config, logger
from manim.constants import *

View file

@ -76,7 +76,7 @@ from manim.typing import Point3D
from manim.utils.color import ManimColor, ParsableManimColor, color_gradient
if TYPE_CHECKING:
from typing_extensions import Self
from typing import Self
from manim.typing import Point3D

View file

@ -132,7 +132,7 @@ class Polyhedron(VGroup):
"""Creates list of cyclic pairwise tuples."""
edges: list[tuple[int, int]] = []
for face in faces_list:
edges += zip(face, face[1:] + face[:1])
edges += zip(face, face[1:] + face[:1], strict=False)
return edges
def create_faces(

View file

@ -17,10 +17,9 @@ __all__ = [
]
from collections.abc import Callable, Iterable, Sequence
from typing import TYPE_CHECKING, Any, Literal
from typing import TYPE_CHECKING, Any, Literal, Self
import numpy as np
from typing_extensions import Self
from manim import config, logger
from manim.constants import *

View file

@ -24,8 +24,9 @@ from ...utils.images import change_to_rgba_array, get_full_raster_image_path
__all__ = ["ImageMobject", "ImageMobjectFromCamera"]
if TYPE_CHECKING:
from typing import Self
import numpy.typing as npt
from typing_extensions import Self
from manim.typing import PixelArray, StrPath

View file

@ -30,8 +30,9 @@ from ...utils.iterables import stretch_array_to_length
__all__ = ["PMobject", "Mobject1D", "Mobject2D", "PGroup", "PointCloudDot", "Point"]
if TYPE_CHECKING:
from typing import Self
import numpy.typing as npt
from typing_extensions import Self
from manim.typing import (
FloatRGBA_Array,
@ -198,7 +199,7 @@ class PMobject(Mobject, metaclass=ConvertToOpenGL):
def ingest_submobjects(self) -> Self:
attrs = self.get_array_attrs()
arrays = list(map(self.get_merged_array, attrs))
for attr, array in zip(attrs, arrays):
for attr, array in zip(attrs, arrays, strict=False):
setattr(self, attr, array)
self.submobjects = []
return self

View file

@ -47,8 +47,9 @@ from manim.utils.iterables import (
from manim.utils.space_ops import rotate_vector, shoelace_direction
if TYPE_CHECKING:
from typing import Self
import numpy.typing as npt
from typing_extensions import Self
from manim.typing import (
CubicBezierPath,
@ -233,7 +234,10 @@ class VMobject(Mobject):
o if (o is not None) else 0.0 for o in tuplify(opacity)
]
rgbas: FloatRGBA_Array = np.array(
[c.to_rgba_with_alpha(o) for c, o in zip(*make_even(colors, opacities))],
[
c.to_rgba_with_alpha(o)
for c, o in zip(*make_even(colors, opacities), strict=False)
],
)
sheen_factor = self.get_sheen_factor()
@ -457,7 +461,7 @@ class VMobject(Mobject):
return self
elif len(submobs2) == 0:
submobs2 = [vmobject]
for sm1, sm2 in zip(*make_even(submobs1, submobs2)):
for sm1, sm2 in zip(*make_even(submobs1, submobs2), strict=False):
sm1.match_style(sm2)
return self
@ -1333,7 +1337,7 @@ class VMobject(Mobject):
split_indices = [0] + list(filtered) + [len(points)]
return (
points[i1:i2]
for i1, i2 in zip(split_indices, split_indices[1:])
for i1, i2 in zip(split_indices, split_indices[1:], strict=False)
if (i2 - i1) >= nppcc
)
@ -1687,7 +1691,7 @@ class VMobject(Mobject):
s = self.get_start_anchors()
e = self.get_end_anchors()
return list(it.chain.from_iterable(zip(s, e)))
return list(it.chain.from_iterable(zip(s, e, strict=False)))
def get_points_defining_boundary(self) -> Point3D_Array:
# Probably returns all anchors, but this is weird regarding the name of the method.

View file

@ -13,7 +13,7 @@ from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL
from manim.utils.paths import straight_path
if TYPE_CHECKING:
from typing_extensions import Self
from typing import Self
from manim.typing import PathFuncType

View file

@ -40,7 +40,7 @@ from .vectorized_mobject_rendering import (
)
if TYPE_CHECKING:
from typing_extensions import Self
from typing import Self
from manim.animation.animation import Animation
from manim.mobject.mobject import Mobject

View file

@ -6,12 +6,11 @@ import re
import textwrap
from collections.abc import Callable, Iterator, Sequence
from pathlib import Path
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, Self, TypeAlias
import moderngl
import numpy as np
import numpy.typing as npt
from typing_extensions import Self, TypeAlias
if TYPE_CHECKING:
from manim.renderer.opengl_renderer import OpenGLRenderer

View file

@ -5,12 +5,11 @@ import logging
import re
from collections.abc import Mapping, Sequence
from pathlib import Path
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Self, TypeAlias
import moderngl
import numpy as np
import numpy.typing as npt
from typing_extensions import Self, TypeAlias
if TYPE_CHECKING:
from manim.typing import FloatRGBLike_Array

View file

@ -33,7 +33,7 @@ except ImportError:
dearpygui_imported = False
from collections.abc import Callable, Iterable, Sequence
from typing import TYPE_CHECKING, Any, Union
from typing import TYPE_CHECKING, Any
import numpy as np
from tqdm import tqdm
@ -62,14 +62,13 @@ from ..utils.module_ops import scene_classes_from_file
if TYPE_CHECKING:
from types import FrameType
from typing_extensions import Self, TypeAlias
from typing import Self, TypeAlias
from manim.typing import Point3D
SceneInteractAction: TypeAlias = Union[
MethodWithArgs, "SceneInteractContinue", "SceneInteractRerun"
]
SceneInteractAction: TypeAlias = (
MethodWithArgs | "SceneInteractContinue" | "SceneInteractRerun"
)
"""The SceneInteractAction type alias is used for elements in the queue
used by :meth:`.Scene.interact()`.

View file

@ -45,7 +45,7 @@ from ..utils.rate_functions import rush_from, rush_into
from ..utils.space_ops import angle_of_vector
if TYPE_CHECKING:
from typing_extensions import Self
from typing import Self
from manim.typing import (
MappingFunction,
@ -682,7 +682,9 @@ class LinearTransformationScene(VectorScene):
default_configs: Iterable[dict[str, Any]],
passed_configs: Iterable[dict[str, Any] | None],
) -> None:
for default_config, passed_config in zip(default_configs, passed_configs):
for default_config, passed_config in zip(
default_configs, passed_configs, strict=False
):
if passed_config is not None:
update_dict_recursively(default_config, passed_config)

View file

@ -22,11 +22,10 @@ from __future__ import annotations
from collections.abc import Callable, Sequence
from os import PathLike
from typing import Union
from typing import TypeAlias
import numpy as np
import numpy.typing as npt
from typing_extensions import TypeAlias
__all__ = [
"ManimFloat",
@ -157,7 +156,7 @@ Its components describe, in order, the intensity of Red, Green, and
Blue in the represented color.
"""
FloatRGBLike: TypeAlias = Union[FloatRGB, tuple[float, float, float]]
FloatRGBLike: TypeAlias = FloatRGB | tuple[float, float, float]
"""``shape: (3,)``
An array of 3 floats between 0 and 1, representing a color in RGB
@ -173,7 +172,7 @@ FloatRGB_Array: TypeAlias = npt.NDArray[ManimColorDType]
A :class:`numpy.ndarray` of many rows of 3 floats representing RGB colors.
"""
FloatRGBLike_Array: TypeAlias = Union[FloatRGB_Array, Sequence[FloatRGBLike]]
FloatRGBLike_Array: TypeAlias = FloatRGB_Array | Sequence[FloatRGBLike]
"""``shape: (M, 3)``
An array of many rows of 3 floats representing RGB colors.
@ -192,7 +191,7 @@ Its components describe, in order, the intensity of Red, Green, and
Blue in the represented color.
"""
IntRGBLike: TypeAlias = Union[IntRGB, tuple[int, int, int]]
IntRGBLike: TypeAlias = IntRGB | tuple[int, int, int]
"""``shape: (3,)``
An array of 3 integers between 0 and 255, representing a color in RGB
@ -212,7 +211,7 @@ Its components describe, in order, the intensity of Red, Green, Blue
and Alpha (opacity) in the represented color.
"""
FloatRGBALike: TypeAlias = Union[FloatRGBA, tuple[float, float, float, float]]
FloatRGBALike: TypeAlias = FloatRGBA | tuple[float, float, float, float]
"""``shape: (4,)``
An array of 4 floats between 0 and 1, representing a color in RGBA
@ -228,7 +227,7 @@ FloatRGBA_Array: TypeAlias = npt.NDArray[ManimColorDType]
A :class:`numpy.ndarray` of many rows of 4 floats representing RGBA colors.
"""
FloatRGBALike_Array: TypeAlias = Union[FloatRGBA_Array, Sequence[FloatRGBALike]]
FloatRGBALike_Array: TypeAlias = FloatRGBA_Array | Sequence[FloatRGBALike]
"""``shape: (M, 4)``
An array of many rows of 4 floats representing RGBA colors.
@ -247,7 +246,7 @@ Its components describe, in order, the intensity of Red, Green, Blue
and Alpha (opacity) in the represented color.
"""
IntRGBALike: TypeAlias = Union[IntRGBA, tuple[int, int, int, int]]
IntRGBALike: TypeAlias = IntRGBA | tuple[int, int, int, int]
"""``shape: (4,)``
An array of 4 integers between 0 and 255, representing a color in RGBA
@ -344,7 +343,7 @@ Point2D: TypeAlias = npt.NDArray[PointDType]
A NumPy array representing a 2-dimensional point: ``[float, float]``.
"""
Point2DLike: TypeAlias = Union[Point2D, tuple[float, float]]
Point2DLike: TypeAlias = Point2D | tuple[float, float]
"""``shape: (2,)``
A 2-dimensional point: ``[float, float]``.
@ -360,7 +359,7 @@ A NumPy array representing a sequence of :class:`.Point2D` objects:
``[[float, float], ...]``.
"""
Point2DLike_Array: TypeAlias = Union[Point2D_Array, Sequence[Point2DLike]]
Point2DLike_Array: TypeAlias = Point2D_Array | Sequence[Point2DLike]
"""``shape: (M, 2)``
An array of :class:`.Point2DLike` objects: ``[[float, float], ...]``.
@ -378,7 +377,7 @@ Point3D: TypeAlias = npt.NDArray[PointDType]
A NumPy array representing a 3-dimensional point: ``[float, float, float]``.
"""
Point3DLike: TypeAlias = Union[Point3D, tuple[float, float, float]]
Point3DLike: TypeAlias = Point3D | tuple[float, float, float]
"""``shape: (3,)``
A 3-dimensional point: ``[float, float, float]``.
@ -394,7 +393,7 @@ A NumPy array representing a sequence of :class:`.Point3D` objects:
``[[float, float, float], ...]``.
"""
Point3DLike_Array: TypeAlias = Union[Point3D_Array, Sequence[Point3DLike]]
Point3DLike_Array: TypeAlias = Point3D_Array | Sequence[Point3DLike]
"""``shape: (M, 3)``
An array of :class:`.Point3DLike` objects: ``[[float, float, float], ...]``.
@ -412,7 +411,7 @@ PointND: TypeAlias = npt.NDArray[PointDType]
A NumPy array representing an N-dimensional point: ``[float, ...]``.
"""
PointNDLike: TypeAlias = Union[PointND, Sequence[float]]
PointNDLike: TypeAlias = PointND | Sequence[float]
"""``shape: (N,)``
An N-dimensional point: ``[float, ...]``.
@ -428,7 +427,7 @@ A NumPy array representing a sequence of :class:`.PointND` objects:
``[[float, ...], ...]``.
"""
PointNDLike_Array: TypeAlias = Union[PointND_Array, Sequence[PointNDLike]]
PointNDLike_Array: TypeAlias = PointND_Array | Sequence[PointNDLike]
"""``shape: (M, N)``
An array of :class:`.PointNDLike` objects: ``[[float, ...], ...]``.
@ -456,7 +455,7 @@ A NumPy array representing a 2-dimensional vector: ``[float, float]``.
VMobjects!
"""
Vector2DLike: TypeAlias = Union[npt.NDArray[PointDType], tuple[float, float]]
Vector2DLike: TypeAlias = npt.NDArray[PointDType] | tuple[float, float]
"""``shape: (2,)``
A 2-dimensional vector: ``[float, float]``.
@ -476,7 +475,7 @@ A NumPy array representing a sequence of :class:`.Vector2D` objects:
``[[float, float], ...]``.
"""
Vector2DLike_Array: TypeAlias = Union[Vector2D_Array, Sequence[Vector2DLike]]
Vector2DLike_Array: TypeAlias = Vector2D_Array | Sequence[Vector2DLike]
"""``shape: (M, 2)``
An array of :class:`.Vector2DLike` objects: ``[[float, float], ...]``.
@ -495,7 +494,7 @@ A NumPy array representing a 3-dimensional vector: ``[float, float, float]``.
VMobjects!
"""
Vector3DLike: TypeAlias = Union[npt.NDArray[PointDType], tuple[float, float, float]]
Vector3DLike: TypeAlias = npt.NDArray[PointDType] | tuple[float, float, float]
"""``shape: (3,)``
A 3-dimensional vector: ``[float, float, float]``.
@ -515,7 +514,7 @@ An NumPy array representing a sequence of :class:`.Vector3D` objects:
``[[float, float, float], ...]``.
"""
Vector3DLike_Array: TypeAlias = Union[npt.NDArray[PointDType], Sequence[Vector3DLike]]
Vector3DLike_Array: TypeAlias = npt.NDArray[PointDType] | Sequence[Vector3DLike]
"""``shape: (M, 3)``
An array of :class:`.Vector3DLike` objects: ``[[float, float, float], ...]``.
@ -535,7 +534,7 @@ A NumPy array representing an :math:`N`-dimensional vector: ``[float, ...]``.
collisions.
"""
VectorNDLike: TypeAlias = Union[npt.NDArray[PointDType], Sequence[float]]
VectorNDLike: TypeAlias = npt.NDArray[PointDType] | Sequence[float]
"""``shape (N,)``
An :math:`N`-dimensional vector: ``[float, ...]``.
@ -556,7 +555,7 @@ A NumPy array representing a sequence of :class:`.VectorND` objects:
``[[float, ...], ...]``.
"""
VectorNDLike_Array: TypeAlias = Union[npt.NDArray[PointDType], Sequence[VectorNDLike]]
VectorNDLike_Array: TypeAlias = npt.NDArray[PointDType] | Sequence[VectorNDLike]
"""``shape (M, N)``
An array of :class:`.VectorNDLike` objects: ``[[float, ...], ...]``.
@ -610,9 +609,9 @@ curve:
``[[float, float, float], [float, float, float], [float, float, float]]``.
"""
QuadraticBezierPointsLike: TypeAlias = Union[
QuadraticBezierPoints, tuple[Point3DLike, Point3DLike, Point3DLike]
]
QuadraticBezierPointsLike: TypeAlias = (
QuadraticBezierPoints | tuple[Point3DLike, Point3DLike, Point3DLike]
)
"""``shape: (3, 3)``
A :class:`.Point3DLike_Array` of three 3D control points for a single quadratic Bézier
@ -630,9 +629,9 @@ A NumPy array containing :math:`N` :class:`.QuadraticBezierPoints` objects:
``[[[float, float, float], [float, float, float], [float, float, float]], ...]``.
"""
QuadraticBezierPointsLike_Array: TypeAlias = Union[
QuadraticBezierPoints_Array, Sequence[QuadraticBezierPointsLike]
]
QuadraticBezierPointsLike_Array: TypeAlias = (
QuadraticBezierPoints_Array | Sequence[QuadraticBezierPointsLike]
)
"""``shape: (N, 3, 3)``
A sequence of :math:`N` :class:`.QuadraticBezierPointsLike` objects:
@ -701,9 +700,9 @@ A :class:`.Point3D_Array` of four 3D control points for a single cubic Bézier c
``[[float, float, float], [float, float, float], [float, float, float], [float, float, float]]``.
"""
CubicBezierPointsLike: TypeAlias = Union[
CubicBezierPoints, tuple[Point3DLike, Point3DLike, Point3DLike, Point3DLike]
]
CubicBezierPointsLike: TypeAlias = (
CubicBezierPoints | tuple[Point3DLike, Point3DLike, Point3DLike, Point3DLike]
)
"""``shape: (4, 3)``
A :class:`.Point3DLike_Array` of 4 control points for a single cubic Bézier curve:
@ -720,9 +719,9 @@ A NumPy array containing :math:`N` :class:`.CubicBezierPoints` objects:
``[[[float, float, float], [float, float, float], [float, float, float], [float, float, float]], ...]``.
"""
CubicBezierPointsLike_Array: TypeAlias = Union[
CubicBezierPoints_Array, Sequence[CubicBezierPointsLike]
]
CubicBezierPointsLike_Array: TypeAlias = (
CubicBezierPoints_Array | Sequence[CubicBezierPointsLike]
)
"""``shape: (N, 4, 3)``
A sequence of :math:`N` :class:`.CubicBezierPointsLike` objects:
@ -823,9 +822,7 @@ Please refer to the documentation of the function you are using for
further type information.
"""
BezierPointsLike_Array: TypeAlias = Union[
BezierPoints_Array, Sequence[BezierPointsLike]
]
BezierPointsLike_Array: TypeAlias = BezierPoints_Array | Sequence[BezierPointsLike]
r"""``shape: (N, PPC, 3)``
A sequence of :math:`N` :class:`.BezierPointsLike` objects containing
@ -898,7 +895,7 @@ Please refer to the documentation of the function you are using for
further type information.
"""
FlatBezierPoints: TypeAlias = Union[npt.NDArray[PointDType], tuple[float, ...]]
FlatBezierPoints: TypeAlias = npt.NDArray[PointDType] | tuple[float, ...]
"""``shape: (3*PPC*N,)``
A flattened array of Bézier control points:
@ -979,12 +976,12 @@ value is an :class:`.RGBA_Array_Int` object.
Path types
"""
StrPath: TypeAlias = Union[str, PathLike[str]]
StrPath: TypeAlias = str | PathLike[str]
"""A string or :class:`.os.PathLike` representing a path to a
directory or file.
"""
StrOrBytesPath: TypeAlias = Union[str, bytes, PathLike[str], PathLike[bytes]]
StrOrBytesPath: TypeAlias = str | bytes | PathLike[str] | PathLike[bytes]
"""A string, bytes or :class:`.os.PathLike` object representing a path
to a directory or file.
"""

View file

@ -999,7 +999,7 @@ def bezier_remap(
new_tuples = np.empty((new_number_of_curves, nppc, dim))
index = 0
for curve, sf in zip(bezier_tuples, split_factors):
for curve, sf in zip(bezier_tuples, split_factors, strict=False):
new_tuples[index : index + sf] = subdivide_bezier(curve, sf).reshape(
sf, nppc, dim
)

View file

@ -70,11 +70,11 @@ import colorsys
import random
import re
from collections.abc import Iterable, Sequence
from typing import TypeVar, Union, overload
from typing import Self, TypeAlias, TypeVar, overload
import numpy as np
import numpy.typing as npt
from typing_extensions import Self, TypeAlias, TypeIs, override
from typing_extensions import TypeIs, override
from manim.typing import (
FloatHSL,
@ -1211,15 +1211,9 @@ class HSV(ManimColor):
self.__alpha = value[3]
ParsableManimColor: TypeAlias = Union[
ManimColor,
int,
str,
IntRGBLike,
FloatRGBLike,
IntRGBALike,
FloatRGBALike,
]
ParsableManimColor: TypeAlias = (
ManimColor | int | str | IntRGBLike | FloatRGBLike | IntRGBALike | FloatRGBALike
)
"""`ParsableManimColor` represents all the types which can be parsed
to a :class:`ManimColor` in Manim.
"""
@ -1424,7 +1418,7 @@ def color_gradient(
floors[-1] = num_colors - 2
return [
rgb_to_color((rgbs[i] * (1 - alpha)) + (rgbs[i + 1] * alpha))
for i, alpha in zip(floors, alphas_mod1)
for i, alpha in zip(floors, alphas_mod1, strict=False)
]

View file

@ -6,9 +6,7 @@ import ast
import sys
from ast import Attribute, Name, Subscript
from pathlib import Path
from typing import Any
from typing_extensions import TypeAlias
from typing import Any, TypeAlias
__all__ = ["parse_module_attributes"]

View file

@ -58,7 +58,7 @@ def adjacent_n_tuples(objects: Sequence[T], n: int) -> zip[tuple[T, ...]]:
>>> list(adjacent_n_tuples([1, 2, 3, 4], 3))
[(1, 2, 3), (2, 3, 4), (3, 4, 1), (4, 1, 2)]
"""
return zip(*([*objects[k:], *objects[:k]] for k in range(n)))
return zip(*([*objects[k:], *objects[:k]] for k in range(n)), strict=False)
def adjacent_pairs(objects: Sequence[T]) -> zip[tuple[T, ...]]:

View file

@ -9,8 +9,9 @@ from manim._config import config
from manim.typing import ManimFloat
if TYPE_CHECKING:
from typing import TypeAlias
import numpy.typing as npt
from typing_extensions import TypeAlias
from manim.typing import MatrixMN, Point3D

View file

@ -609,7 +609,7 @@ def find_intersection(
# algorithm from https://en.wikipedia.org/wiki/Skew_lines#Nearest_points
result = []
for p0, v0, p1, v1 in zip(p0s, v0s, p1s, v1s):
for p0, v0, p1, v1 in zip(p0s, v0s, p1s, v1s, strict=False):
normal = cross(v1, cross(v0, v1))
denom = max(np.dot(v0, normal), threshold)
result += [p0 + np.dot(p1 - p0, normal) / denom * v0]
@ -736,7 +736,9 @@ def earclip_triangulation(verts: np.ndarray, ring_ends: list) -> list:
# with holes is instead treated as a (very convex)
# polygon with one edge. Do this by drawing connections
# between rings close to each other
rings = [list(range(e0, e1)) for e0, e1 in zip([0, *ring_ends], ring_ends)]
rings = [
list(range(e0, e1)) for e0, e1 in zip([0, *ring_ends], ring_ends, strict=False)
]
attached_rings = rings[:1]
detached_rings = rings[1:]
loop_connections = {}

View file

@ -14,7 +14,7 @@ from pathlib import Path
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from typing_extensions import Self
from typing import Self
from manim.typing import StrPath

110
mypy.ini
View file

@ -1,7 +1,7 @@
[mypy]
strict = False
files = manim
python_version = 3.10
python_version = 3.11
; plugins = numpy.typing.mypy_plugin
ignore_errors = False
cache_fine_grained = True
@ -52,18 +52,30 @@ warn_return_any = True
#
# disable_recursive_aliases = True
[mypy-manim.__main__]
ignore_errors = True
[mypy-manim._config.utils]
ignore_errors = True
[mypy-manim._config.cli_colors]
ignore_errors = True
[mypy-manim.animation.animation]
ignore_errors = True
[mypy-manim.animation.creation]
ignore_errors = True
[mypy-manim.animation.indication]
ignore_errors = True
[mypy-manim.animation.rotation]
ignore_errors = True
[mypy-manim.animation.specialized]
ignore_errors = True
[mypy-manim.animation.speedmodifier]
ignore_errors = True
@ -76,9 +88,21 @@ ignore_errors = True
[mypy-manim.animation.updaters.mobject_update_utils]
ignore_errors = True
[mypy-manim.camera.camera]
ignore_errors = True
[mypy-manim.camera.mapping_camera]
ignore_errors = True
[mypy-manim.cli.default_group]
ignore_errors = True
[mypy-manim.mobject.geometry.boolean_ops]
ignore_errors = True
[mypy-manim.mobject.geometry.polygram]
ignore_errors = True
[mypy-manim.mobject.graphing.coordinate_systems]
ignore_errors = True
@ -133,6 +157,90 @@ ignore_errors = True
[mypy-manim.utils.hashing]
ignore_errors = True
# Added temporarily due to current mypy failures
[mypy-manim.camera.three_d_camera]
ignore_errors = True
[mypy-manim.mobject.graphing.functions]
ignore_errors = True
[mypy-manim.mobject.graphing.number_line]
ignore_errors = True
[mypy-manim.mobject.graphing.probability]
ignore_errors = True
[mypy-manim.mobject.graphing.scale]
ignore_errors = True
[mypy-manim.mobject.matrix]
ignore_errors = True
[mypy-manim.mobject.opengl.opengl_geometry]
ignore_errors = True
[mypy-manim.mobject.opengl.opengl_mobject]
ignore_errors = True
[mypy-manim.mobject.svg.brace]
ignore_errors = True
[mypy-manim.mobject.svg.svg_mobject]
ignore_errors = True
[mypy-manim.mobject.text.code_mobject]
ignore_errors = True
[mypy-manim.mobject.three_d.polyhedra]
ignore_errors = True
[mypy-manim.mobject.three_d.three_d_utils]
ignore_errors = True
[mypy-manim.mobject.three_d.three_dimensions]
ignore_errors = True
[mypy-manim.renderer.shader]
ignore_errors = True
[mypy-manim.renderer.vectorized_mobject_rendering]
ignore_errors = True
[mypy-manim.scene.scene]
ignore_errors = True
[mypy-manim.scene.scene_file_writer]
ignore_errors = True
[mypy-manim.scene.vector_space_scene]
ignore_errors = True
[mypy-manim.utils.bezier]
ignore_errors = True
[mypy-manim.utils.color.core]
ignore_errors = True
[mypy-manim.utils.commands]
ignore_errors = True
[mypy-manim.utils.images]
ignore_errors = True
[mypy-manim.utils.iterables]
ignore_errors = True
[mypy-manim.utils.opengl]
ignore_errors = True
[mypy-manim.utils.paths]
ignore_errors = True
[mypy-manim.utils.space_ops]
ignore_errors = True
[mypy-manim.utils.testing._test_class_makers]
ignore_errors = True
# ---------------- Stubless imported Modules --------------------------

View file

@ -130,7 +130,7 @@ exclude_lines = ["pragma: no cover", "if TYPE_CHECKING:"]
[tool.ruff]
line-length = 88
target-version = "py39"
target-version = "py311"
extend-exclude = [
".github",
".hg",

View file

@ -89,7 +89,7 @@ def test_Polygram_get_vertex_groups():
for vertex_groups in vertex_groups_arr:
polygram = Polygram(*vertex_groups)
poly_vertex_groups = polygram.get_vertex_groups()
for poly_group, group in zip(poly_vertex_groups, vertex_groups):
for poly_group, group in zip(poly_vertex_groups, vertex_groups, strict=False):
np.testing.assert_array_equal(poly_group, group)
# If polygram is a Polygram of a vertex group containing the start vertex N times,

View file

@ -152,7 +152,7 @@ def test_coords_to_point_vectorized():
def ref_func(*coords):
result = np.array(origin)
for axis, number in zip(plane.get_axes(), coords):
for axis, number in zip(plane.get_axes(), coords, strict=False):
result += axis.number_to_point(number) - origin
return result

View file

@ -62,7 +62,7 @@ def test_add_labels():
expected_label_length = 6
num_line = NumberLine(x_range=[-4, 4])
num_line.add_labels(
dict(zip(list(range(-3, 3)), [Integer(m) for m in range(-1, 5)])),
dict(zip(list(range(-3, 3)), [Integer(m) for m in range(-1, 5)], strict=False)),
)
actual_label_length = len(num_line.labels)
assert actual_label_length == expected_label_length, (

View file

@ -108,6 +108,7 @@ def test_multi_part_tex_with_empty_parts():
for one_part_glyph, multi_part_glyph in zip(
one_part_fomula.family_members_with_points(),
multi_part_formula.family_members_with_points(),
strict=False,
):
np.testing.assert_allclose(one_part_glyph.points, multi_part_glyph.points)

View file

@ -369,7 +369,7 @@ def test_vdict_init():
# Test VDict made from a python dict
VDict({"a": VMobject(), "b": VMobject(), "c": VMobject()})
# Test VDict made using zip
VDict(zip(["a", "b", "c"], [VMobject(), VMobject(), VMobject()]))
VDict(zip(["a", "b", "c"], [VMobject(), VMobject(), VMobject()], strict=False))
# If the value is of type Mobject, must raise a TypeError
with pytest.raises(TypeError):
VDict({"a": Mobject()})

View file

@ -62,7 +62,7 @@ def test_add_labels():
expected_label_length = 6
num_line = NumberLine(x_range=[-4, 4])
num_line.add_labels(
dict(zip(list(range(-3, 3)), [Integer(m) for m in range(-1, 5)])),
dict(zip(list(range(-3, 3)), [Integer(m) for m in range(-1, 5)], strict=False)),
)
actual_label_length = len(num_line.labels)
assert actual_label_length == expected_label_length, (

View file

@ -308,7 +308,13 @@ def test_vdict_init(using_opengl_renderer):
# Test VDict made from a python dict
VDict({"a": OpenGLVMobject(), "b": OpenGLVMobject(), "c": OpenGLVMobject()})
# Test VDict made using zip
VDict(zip(["a", "b", "c"], [OpenGLVMobject(), OpenGLVMobject(), OpenGLVMobject()]))
VDict(
zip(
["a", "b", "c"],
[OpenGLVMobject(), OpenGLVMobject(), OpenGLVMobject()],
strict=False,
)
)
# If the value is of type OpenGLMobject, must raise a TypeError
with pytest.raises(TypeError):
VDict({"a": OpenGLMobject()})

View file

@ -32,7 +32,7 @@ def test_custom_coordinates(scene):
ax = Axes(x_range=[0, 10])
ax.add_coordinates(
dict(zip(list(range(1, 10)), [Tex("str") for _ in range(1, 10)])),
dict(zip(list(range(1, 10)), [Tex("str") for _ in range(1, 10)], strict=False)),
)
scene.add(ax)

View file

@ -59,7 +59,7 @@ def test_vmobject_joint_types(scene):
]
)
lines = VGroup(*[angled_line.copy() for _ in range(len(LineJointType))])
for line, joint_type in zip(lines, LineJointType):
for line, joint_type in zip(lines, LineJointType, strict=False):
line.joint_type = joint_type
lines.arrange(RIGHT, buff=1)

View file

@ -35,7 +35,9 @@ def _check_logs(reference_logfile_path: Path, generated_logfile_path: Path) -> N
ref_log = json.loads(ref)
gen_log = json.loads(gen)
diff_keys = [
d1[0] for d1, d2 in zip(ref_log.items(), gen_log.items()) if d1[1] != d2[1]
d1[0]
for d1, d2 in zip(ref_log.items(), gen_log.items(), strict=False)
if d1[1] != d2[1]
]
# \n and \t don't not work in f-strings.
newline = "\n"

View file

@ -59,7 +59,7 @@ def check_video_data(path_control_data: Path, path_video_gen: Path) -> None:
f"expected {len(sec_index_exp)} sections ({', '.join([el['name'] for el in sec_index_exp])}), but {len(sec_index_gen)} ({', '.join([el['name'] for el in sec_index_gen])}) got generated (in '{path_sec_index_gen}')"
)
# check individual sections
for sec_gen, sec_exp in zip(sec_index_gen, sec_index_exp):
for sec_gen, sec_exp in zip(sec_index_gen, sec_index_exp, strict=False):
assert_shallow_dict_compare(
sec_gen,
sec_exp,