From 1185095d492665e75ef98dadf5f57053ed9bfe14 Mon Sep 17 00:00:00 2001 From: Henrik Skov Midtiby Date: Mon, 16 Mar 2026 21:31:35 +0100 Subject: [PATCH 1/8] **kwargs: Any # Conflicts: # manim/mobject/table.py --- manim/mobject/table.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/manim/mobject/table.py b/manim/mobject/table.py index dc4519dea3..dc48ad1b86 100644 --- a/manim/mobject/table.py +++ b/manim/mobject/table.py @@ -66,6 +66,7 @@ def construct(self): import itertools as it from collections.abc import Callable, Iterable, Sequence +from typing import Any, Self from manim.mobject.geometry.line import Line from manim.mobject.geometry.polygram import Polygon @@ -204,7 +205,7 @@ def __init__( element_to_mobject_config: dict = {}, arrange_in_grid_config: dict = {}, line_config: dict = {}, - **kwargs, + **kwargs: Any, ): self.row_labels = row_labels self.col_labels = col_labels @@ -753,7 +754,7 @@ def add_background_to_entries(self, color: ParsableManimColor = BLACK) -> Table: mob.add_background_rectangle(color=ManimColor(color)) return self - def get_cell(self, pos: Sequence[int] = (1, 1), **kwargs) -> Polygon: + def get_cell(self, pos: Sequence[int] = (1, 1), **kwargs: Any) -> Polygon: """Returns one specific cell as a rectangular :class:`~.Polygon` without the entry. Parameters @@ -814,7 +815,7 @@ def get_highlighted_cell( self, pos: Sequence[int] = (1, 1), color: ParsableManimColor = PURE_YELLOW, - **kwargs, + **kwargs: Any, ) -> BackgroundRectangle: """Returns a :class:`~.BackgroundRectangle` of the cell at the given position. @@ -853,7 +854,7 @@ def add_highlighted_cell( self, pos: Sequence[int] = (1, 1), color: ParsableManimColor = PURE_YELLOW, - **kwargs, + **kwargs: Any, ) -> Table: """Highlights one cell at a specific position on the table by adding a :class:`~.BackgroundRectangle`. @@ -896,7 +897,7 @@ def create( label_animation: Callable[[VMobject | VGroup], Animation] = Write, element_animation: Callable[[VMobject | VGroup], Animation] = Create, entry_animation: Callable[[VMobject | VGroup], Animation] = FadeIn, - **kwargs, + **kwargs: Any, ) -> AnimationGroup: """Customized create-type function for tables. @@ -963,7 +964,7 @@ def construct(self): return AnimationGroup(*animations, lag_ratio=lag_ratio) - def scale(self, scale_factor: float, **kwargs): + def scale(self, scale_factor: float, **kwargs: Any) -> Self: # h_buff and v_buff must be adjusted so that Table.get_cell # can construct an accurate polygon for a cell. self.h_buff *= scale_factor @@ -996,7 +997,7 @@ def __init__( self, table: Iterable[Iterable[float | str]], element_to_mobject: Callable[[float | str], VMobject] = MathTex, - **kwargs, + **kwargs: Any, ): """ Special case of :class:`~.Table` with `element_to_mobject` set to :class:`~.MathTex`. @@ -1051,7 +1052,7 @@ def __init__( self, table: Iterable[Iterable[VMobject]], element_to_mobject: Callable[[VMobject], VMobject] = lambda m: m, - **kwargs, + **kwargs: Any, ): """ Special case of :class:`~.Table` with ``element_to_mobject`` set to an identity function. @@ -1099,7 +1100,7 @@ def __init__( self, table: Iterable[Iterable[float | str]], element_to_mobject: Callable[[float | str], VMobject] = Integer, - **kwargs, + **kwargs: Any, ): """ Special case of :class:`~.Table` with `element_to_mobject` set to :class:`~.Integer`. @@ -1144,7 +1145,7 @@ def __init__( table: Iterable[Iterable[float | str]], element_to_mobject: Callable[[float | str], VMobject] = DecimalNumber, element_to_mobject_config: dict = {"num_decimal_places": 1}, - **kwargs, + **kwargs: Any, ): """ Special case of :class:`~.Table` with ``element_to_mobject`` set to :class:`~.DecimalNumber`. From 9e627b4905466908abccd0cb6bd72ba0e117ef04 Mon Sep 17 00:00:00 2001 From: Henrik Skov Midtiby Date: Wed, 26 Nov 2025 22:10:13 +0100 Subject: [PATCH 2/8] Iterable -> Sequence --- manim/mobject/table.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/manim/mobject/table.py b/manim/mobject/table.py index dc48ad1b86..55c0ced78b 100644 --- a/manim/mobject/table.py +++ b/manim/mobject/table.py @@ -187,9 +187,9 @@ def construct(self): def __init__( self, - table: Iterable[Iterable[float | str | VMobject]], - row_labels: Iterable[VMobject] | None = None, - col_labels: Iterable[VMobject] | None = None, + table: Sequence[Sequence[float | str | VMobject]], + row_labels: Sequence[VMobject] | None = None, + col_labels: Sequence[VMobject] | None = None, top_left_entry: VMobject | None = None, v_buff: float = 0.8, h_buff: float = 1.3, @@ -275,7 +275,7 @@ def _table_to_mob_table( for row in table ] - def _organize_mob_table(self, table: Iterable[Iterable[VMobject]]) -> VGroup: + def _organize_mob_table(self, table: Sequence[Sequence[VMobject]]) -> VGroup: """Arranges the :class:`~.VMobject` of ``table`` in a grid. Parameters From 5962ef00d1b57ca3877f746d1a4eb8d7abc2063d Mon Sep 17 00:00:00 2001 From: Henrik Skov Midtiby Date: Wed, 26 Nov 2025 22:18:36 +0100 Subject: [PATCH 3/8] Iterable to Sequence and also accept a class for creating mobjects --- manim/mobject/table.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/manim/mobject/table.py b/manim/mobject/table.py index 55c0ced78b..688d4ba1ac 100644 --- a/manim/mobject/table.py +++ b/manim/mobject/table.py @@ -995,8 +995,9 @@ def construct(self): def __init__( self, - table: Iterable[Iterable[float | str]], - element_to_mobject: Callable[[float | str], VMobject] = MathTex, + table: Sequence[Sequence[float | str]], + element_to_mobject: Callable[[float | str], VMobject] + | type[VMobject] = MathTex, **kwargs: Any, ): """ @@ -1050,8 +1051,9 @@ def construct(self): def __init__( self, - table: Iterable[Iterable[VMobject]], - element_to_mobject: Callable[[VMobject], VMobject] = lambda m: m, + table: Sequence[Sequence[VMobject]], + element_to_mobject: Callable[[VMobject], VMobject] + | type[VMobject] = lambda m: m, **kwargs: Any, ): """ @@ -1098,8 +1100,9 @@ def construct(self): def __init__( self, - table: Iterable[Iterable[float | str]], - element_to_mobject: Callable[[float | str], VMobject] = Integer, + table: Sequence[Sequence[float | str]], + element_to_mobject: Callable[[float | str], VMobject] + | type[VMobject] = Integer, **kwargs: Any, ): """ @@ -1142,8 +1145,9 @@ def construct(self): def __init__( self, - table: Iterable[Iterable[float | str]], - element_to_mobject: Callable[[float | str], VMobject] = DecimalNumber, + table: Sequence[Sequence[float | str]], + element_to_mobject: Callable[[float | str], VMobject] + | type[VMobject] = DecimalNumber, element_to_mobject_config: dict = {"num_decimal_places": 1}, **kwargs: Any, ): From a47fa9a74f410223619ccc8d6363546f02ea7450 Mon Sep 17 00:00:00 2001 From: Henrik Skov Midtiby Date: Wed, 26 Nov 2025 22:21:08 +0100 Subject: [PATCH 4/8] Allow a class to be passed --- manim/mobject/table.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manim/mobject/table.py b/manim/mobject/table.py index 688d4ba1ac..913c1fe0cb 100644 --- a/manim/mobject/table.py +++ b/manim/mobject/table.py @@ -201,7 +201,8 @@ def __init__( element_to_mobject: Callable[ [float | str | VMobject], VMobject, - ] = Paragraph, + ] + | type[VMobject] = Paragraph, element_to_mobject_config: dict = {}, arrange_in_grid_config: dict = {}, line_config: dict = {}, From 724e56f2e6363d5e395ef537ae7967506ae2540a Mon Sep 17 00:00:00 2001 From: Henrik Skov Midtiby Date: Wed, 26 Nov 2025 22:30:33 +0100 Subject: [PATCH 5/8] Force some sequences to be lists --- manim/mobject/table.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manim/mobject/table.py b/manim/mobject/table.py index 913c1fe0cb..ba844f3030 100644 --- a/manim/mobject/table.py +++ b/manim/mobject/table.py @@ -321,13 +321,13 @@ def _add_labels(self, mob_table: VGroup) -> VGroup: if self.col_labels is not None: if self.row_labels is not None: if self.top_left_entry is not None: - col_labels = [self.top_left_entry] + self.col_labels + col_labels = [self.top_left_entry] + list(self.col_labels) mob_table.insert(0, col_labels) else: # Placeholder to use arrange_in_grid if top_left_entry is not set. # Import OpenGLVMobject to work with --renderer=opengl dummy_mobject = get_vectorized_mobject_class()() - col_labels = [dummy_mobject] + self.col_labels + col_labels = [dummy_mobject] + list(self.col_labels) mob_table.insert(0, col_labels) else: mob_table.insert(0, self.col_labels) From 1beb814646b67f0a843441d5d9156e5262444bb5 Mon Sep 17 00:00:00 2001 From: Henrik Skov Midtiby Date: Wed, 26 Nov 2025 22:30:44 +0100 Subject: [PATCH 6/8] Sequence to list --- manim/mobject/table.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manim/mobject/table.py b/manim/mobject/table.py index ba844f3030..d835184ca7 100644 --- a/manim/mobject/table.py +++ b/manim/mobject/table.py @@ -938,7 +938,7 @@ def construct(self): self.play(table.create()) self.wait() """ - animations: Sequence[Animation] = [ + animations: list[Animation] = [ line_animation( VGroup(self.vertical_lines, self.horizontal_lines), **kwargs, From 994a3fce0e59bee9223c6035906a06f3da1db9c2 Mon Sep 17 00:00:00 2001 From: Henrik Skov Midtiby Date: Mon, 16 Mar 2026 21:49:31 +0100 Subject: [PATCH 7/8] Work on self.row_labels and self.col_labels --- manim/mobject/table.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/manim/mobject/table.py b/manim/mobject/table.py index d835184ca7..be7fac34b3 100644 --- a/manim/mobject/table.py +++ b/manim/mobject/table.py @@ -208,8 +208,8 @@ def __init__( line_config: dict = {}, **kwargs: Any, ): - self.row_labels = row_labels - self.col_labels = col_labels + self.row_labels = list(row_labels) if row_labels else None + self.col_labels = list(col_labels) if col_labels else None self.top_left_entry = top_left_entry self.row_dim = len(table) self.col_dim = len(table[0]) @@ -232,7 +232,7 @@ def __init__( raise ValueError("Not all rows in table have the same length.") super().__init__(**kwargs) - mob_table = self._table_to_mob_table(table) + mob_table: list[list[VMobject]] = self._table_to_mob_table(table) self.elements_without_labels = VGroup(*it.chain(*mob_table)) mob_table = self._add_labels(mob_table) self._organize_mob_table(mob_table) @@ -254,7 +254,7 @@ def __init__( def _table_to_mob_table( self, table: Iterable[Iterable[float | str | VMobject]], - ) -> list: + ) -> list[list[VMobject]]: """Initializes the entries of ``table`` as :class:`~.VMobject`. Parameters @@ -302,7 +302,7 @@ def _organize_mob_table(self, table: Sequence[Sequence[VMobject]]) -> VGroup: ) return help_table - def _add_labels(self, mob_table: VGroup) -> VGroup: + def _add_labels(self, mob_table: list[list[VMobject]]) -> list[list[VMobject]]: """Adds labels to an in a grid arranged :class:`~.VGroup`. Parameters @@ -684,7 +684,10 @@ def construct(self): item.set_color(random_bright_color()) self.add(table) """ - return VGroup(*self.row_labels) + if self.row_labels: + return VGroup(*self.row_labels) + else: + return VGroup() def get_col_labels(self) -> VGroup: """Return the column labels of the table. @@ -712,7 +715,10 @@ def construct(self): item.set_color(random_bright_color()) self.add(table) """ - return VGroup(*self.col_labels) + if self.col_labels: + return VGroup(*self.col_labels) + else: + return VGroup() def get_labels(self) -> VGroup: """Returns the labels of the table. From dfbdc8b3f01c74949274c31ca5c7033f2d4549f6 Mon Sep 17 00:00:00 2001 From: Henrik Skov Midtiby Date: Mon, 16 Mar 2026 21:58:57 +0100 Subject: [PATCH 8/8] Deal with the last typing errors in table.py --- manim/mobject/table.py | 18 +++++++++++++++--- mypy.ini | 3 --- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/manim/mobject/table.py b/manim/mobject/table.py index be7fac34b3..87592f8da8 100644 --- a/manim/mobject/table.py +++ b/manim/mobject/table.py @@ -199,6 +199,14 @@ def __init__( include_background_rectangle: bool = False, background_rectangle_color: ParsableManimColor = BLACK, element_to_mobject: Callable[ + [float | str], + VMobject, + ] + | Callable[ + [VMobject], + VMobject, + ] + | Callable[ [float | str | VMobject], VMobject, ] @@ -270,7 +278,9 @@ def _table_to_mob_table( """ return [ [ - self.element_to_mobject(item, **self.element_to_mobject_config) + # error: Argument 1 has incompatible type "float | str | VMobject"; expected "float | str" [arg-type] + # error: Argument 1 has incompatible type "float | str | VMobject"; expected "VMobject" [arg-type] + self.element_to_mobject(item, **self.element_to_mobject_config) # type: ignore[arg-type] for item in row ] for row in table @@ -971,12 +981,14 @@ def construct(self): return AnimationGroup(*animations, lag_ratio=lag_ratio) - def scale(self, scale_factor: float, **kwargs: Any) -> Self: + def scale( + self, scale_factor: float, scale_stroke: bool = False, **kwargs: Any + ) -> Self: # h_buff and v_buff must be adjusted so that Table.get_cell # can construct an accurate polygon for a cell. self.h_buff *= scale_factor self.v_buff *= scale_factor - super().scale(scale_factor, **kwargs) + super().scale(scale_factor, scale_stroke=scale_stroke, **kwargs) return self diff --git a/mypy.ini b/mypy.ini index 0ee928de4c..c20bffe8f3 100644 --- a/mypy.ini +++ b/mypy.ini @@ -94,9 +94,6 @@ ignore_errors = True [mypy-manim.mobject.opengl.opengl_vectorized_mobject] ignore_errors = True -[mypy-manim.mobject.table] -ignore_errors = True - [mypy-manim.mobject.types.point_cloud_mobject] ignore_errors = True