Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
af65634
Add type annotations to `mobject.py`
henrikmidtiby Aug 5, 2025
8df3447
More work on type annotations for mobject.py
henrikmidtiby Aug 5, 2025
b502836
...
henrikmidtiby Aug 5, 2025
72deed5
Merge branch 'main' into TypingMobject
henrikmidtiby Aug 10, 2025
07e1074
Almost handled all mypy errors
henrikmidtiby Aug 10, 2025
4af521c
Add the mypy error messages to the lines that trigger them
henrikmidtiby Aug 10, 2025
7183ad1
Use typing.cast to avoid some mypy errors, as suggested by JasonGrace…
henrikmidtiby Aug 10, 2025
d0e603e
Used the ruff linter
henrikmidtiby Aug 10, 2025
acc2ff8
Fixed one typing issue and added the error descriptions to the source…
henrikmidtiby Aug 10, 2025
01f33a0
Set the type of the elements in a VGroup to VMobject
henrikmidtiby Aug 10, 2025
baf7e3d
Use typing.cast to handle some specific cases.
henrikmidtiby Aug 10, 2025
6dbfcf8
Code cleaning
henrikmidtiby Aug 10, 2025
62513fd
Updates
henrikmidtiby Aug 10, 2025
37aaa7f
Merge remote-tracking branch 'upstream/main' into TypingMobject
henrikmidtiby Aug 10, 2025
107fbe2
When started to use typing.cast it is needed to import / define certa…
henrikmidtiby Aug 11, 2025
3a2f3b5
Fix bug introduced with the type annotations.
henrikmidtiby Aug 11, 2025
c75fbdc
Made it work again
henrikmidtiby Aug 11, 2025
34ecaf7
..
henrikmidtiby Aug 11, 2025
17ca755
Fixed more issues.
henrikmidtiby Aug 11, 2025
061e033
Code cleanup
henrikmidtiby Aug 11, 2025
618c885
Merge remote-tracking branch 'upstream/main' into TypingMobject
henrikmidtiby Aug 13, 2025
84bdfe2
Code cleanup.
henrikmidtiby Aug 13, 2025
a17bb30
Handle slicing when accessing elements inside a VGroup
henrikmidtiby Aug 13, 2025
776865e
Merge remote-tracking branch 'upstream/main' into TypingMobject
henrikmidtiby Aug 21, 2025
e2eaccf
Fix missing issues.
henrikmidtiby Aug 21, 2025
be92b75
Merge remote-tracking branch 'upstream/main' into TypingMobject
henrikmidtiby Aug 21, 2025
8202a40
Silence the last mypy error
henrikmidtiby Aug 21, 2025
3e2a161
Make _Updater, _NonTimeBasedUpdater and _TimeBasedUpdater private.
henrikmidtiby Aug 21, 2025
63ed382
Replace | with Union[...] in one location
henrikmidtiby Aug 21, 2025
a3fe7e4
Move import of Union
henrikmidtiby Aug 21, 2025
15d4832
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions manim/animation/indication.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ def create_lines(self) -> VGroup:
def create_line_anims(self) -> Iterable[ShowPassingFlash]:
return [
ShowPassingFlash(
# error: Argument 1 to "ShowPassingFlash" has incompatible type "Mobject"; expected "VMobject" [arg-type]
line,
time_width=self.time_width,
run_time=self.run_time,
Expand Down
4 changes: 2 additions & 2 deletions manim/camera/moving_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from ..camera.camera import Camera
from ..constants import DOWN, LEFT, RIGHT, UP
from ..mobject.frame import ScreenRectangle
from ..mobject.mobject import Mobject
from ..mobject.mobject import Mobject, _AnimationBuilder
from ..utils.color import WHITE, ManimColor


Expand Down Expand Up @@ -172,7 +172,7 @@ def auto_zoom(
margin: float = 0,
only_mobjects_in_frame: bool = False,
animate: bool = True,
) -> Mobject:
) -> _AnimationBuilder | Mobject:
"""Zooms on to a given array of mobjects (or a singular mobject)
and automatically resizes to frame all the mobjects.

Expand Down
10 changes: 6 additions & 4 deletions manim/mobject/geometry/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
"RightAngle",
]

from typing import TYPE_CHECKING, Any, Literal
from typing import TYPE_CHECKING, Any, Literal, cast

import numpy as np

from manim import config
from manim.constants import *
from manim.mobject.geometry.arc import Arc, ArcBetweenPoints, Dot, TipableVMobject
from manim.mobject.geometry.tips import ArrowTriangleFilledTip
from manim.mobject.geometry.tips import ArrowTip, ArrowTriangleFilledTip
from manim.mobject.mobject import Mobject
from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL
from manim.mobject.opengl.opengl_mobject import OpenGLMobject
Expand Down Expand Up @@ -648,9 +648,11 @@ def scale(self, factor: float, scale_tips: bool = False, **kwargs: Any) -> Self:
self._set_stroke_width_from_length()

if has_tip:
self.add_tip(tip=old_tips[0])
# error: Argument "tip" to "add_tip" of "TipableVMobject" has incompatible type "VMobject"; expected "ArrowTip | None" [arg-type]
self.add_tip(tip=cast(ArrowTip, old_tips[0]))
if has_start_tip:
self.add_tip(tip=old_tips[1], at_start=True)
# error: Argument "tip" to "add_tip" of "TipableVMobject" has incompatible type "VMobject"; expected "ArrowTip | None" [arg-type]
self.add_tip(tip=cast(ArrowTip, old_tips[1]), at_start=True)
return self

def get_normal_vector(self) -> Vector3D:
Expand Down
4 changes: 2 additions & 2 deletions manim/mobject/graphing/probability.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ def add_braces_and_labels(self) -> None:
if hasattr(parts, subattr):
self.add(getattr(parts, subattr))

def __getitem__(self, index: int) -> SampleSpace:
def __getitem__(self, index: int) -> VMobject:
if hasattr(self, "horizontal_parts"):
val: SampleSpace = self.horizontal_parts[index]
val: VMobject = self.horizontal_parts[index]
return val
elif hasattr(self, "vertical_parts"):
val = self.vertical_parts[index]
Expand Down
15 changes: 7 additions & 8 deletions manim/mobject/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def construct(self):
import numpy as np
from typing_extensions import Self

from manim.mobject.mobject import Mobject
from manim.mobject.opengl.opengl_compatibility import ConvertToOpenGL
from manim.mobject.text.numbers import DecimalNumber, Integer
from manim.mobject.text.tex_mobject import MathTex, Tex
Expand Down Expand Up @@ -172,7 +171,7 @@ def __init__(
bracket_v_buff: float = MED_SMALL_BUFF,
add_background_rectangles_to_entries: bool = False,
include_background_rectangle: bool = False,
element_to_mobject: type[Mobject] | Callable[..., Mobject] = MathTex,
element_to_mobject: type[VMobject] | Callable[..., VMobject] = MathTex,
element_to_mobject_config: dict = {},
element_alignment_corner: Sequence[float] = DR,
left_bracket: str = "[",
Expand Down Expand Up @@ -207,7 +206,7 @@ def __init__(
if self.include_background_rectangle:
self.add_background_rectangle()

def _matrix_to_mob_matrix(self, matrix: np.ndarray) -> list[list[Mobject]]:
def _matrix_to_mob_matrix(self, matrix: np.ndarray) -> list[list[VMobject]]:
return [
[
self.element_to_mobject(item, **self.element_to_mobject_config)
Expand All @@ -216,7 +215,7 @@ def _matrix_to_mob_matrix(self, matrix: np.ndarray) -> list[list[Mobject]]:
for row in matrix
]

def _organize_mob_matrix(self, matrix: list[list[Mobject]]) -> Self:
def _organize_mob_matrix(self, matrix: list[list[VMobject]]) -> Self:
for i, row in enumerate(matrix):
for j, _ in enumerate(row):
mob = matrix[i][j]
Expand Down Expand Up @@ -402,7 +401,7 @@ def add_background_to_entries(self) -> Self:
mob.add_background_rectangle()
return self

def get_mob_matrix(self) -> list[list[Mobject]]:
def get_mob_matrix(self) -> list[list[VMobject]]:
"""Return the underlying mob matrix mobjects.

Returns
Expand Down Expand Up @@ -485,7 +484,7 @@ def construct(self):
def __init__(
self,
matrix: Iterable,
element_to_mobject: type[Mobject] = DecimalNumber,
element_to_mobject: type[VMobject] = DecimalNumber,
element_to_mobject_config: dict[str, Any] = {"num_decimal_places": 1},
**kwargs: Any,
):
Expand Down Expand Up @@ -530,7 +529,7 @@ def construct(self):
def __init__(
self,
matrix: Iterable,
element_to_mobject: type[Mobject] = Integer,
element_to_mobject: type[VMobject] = Integer,
**kwargs: Any,
):
"""
Expand Down Expand Up @@ -568,7 +567,7 @@ def construct(self):
def __init__(
self,
matrix: Iterable,
element_to_mobject: type[Mobject] | Callable[..., Mobject] = lambda m: m,
element_to_mobject: type[VMobject] | Callable[..., VMobject] = lambda m: m,
**kwargs: Any,
):
super().__init__(matrix, element_to_mobject=element_to_mobject, **kwargs)
Expand Down
Loading
Loading