Skip to content

Add type annotations to text_mobject.py #4381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Aug 11, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
eabb0ee
Activated typechecking in mobject.text.*
henrikmidtiby Jan 5, 2025
866ea02
Fixed typing errors in mobject/text/code_mobject.py
henrikmidtiby Jan 5, 2025
952b302
Add type annotations to mobject/text/numbers.py
henrikmidtiby Jan 6, 2025
c6f7059
Import ManimColor on every run
henrikmidtiby Jan 6, 2025
648277a
Add type annotations to mobject/text/tex_mobject.py
henrikmidtiby Jan 6, 2025
f56effd
Return the object itself from init_colors
henrikmidtiby Jan 6, 2025
e76e53b
Fix issue.
henrikmidtiby Jan 6, 2025
94382c5
Add type annotations to mobject/text/text_mobject.py
henrikmidtiby Jan 7, 2025
19157a0
Add type annotations to camera/camera.py
henrikmidtiby Jan 10, 2025
94215e0
Remove deprecated code
henrikmidtiby Jul 29, 2025
7f24484
First pass through text_mobject.py for adding type annotations.
henrikmidtiby Jul 29, 2025
1ae6ac5
More work on typing text_mobject.py
henrikmidtiby Jul 31, 2025
46fc244
Merge remote-tracking branch 'upstream/main' into Typing_camera
henrikmidtiby Aug 1, 2025
001e0c8
Hunting down the last typing issues.
henrikmidtiby Aug 8, 2025
2649c5f
Ensure that color_gradient always returns a list
henrikmidtiby Aug 8, 2025
589abb1
Merge remote-tracking branch 'upstream/main' into TypingTextMobject
henrikmidtiby Aug 8, 2025
61a1359
Merge remote-tracking branch 'upstream/main' into Typing_camera
henrikmidtiby Aug 8, 2025
2842c09
Code cleanup
henrikmidtiby Aug 8, 2025
f5529ef
Merge branch 'TypingTextMobject' into Typing_camera
henrikmidtiby Aug 8, 2025
eeacbd7
Code cleanup
henrikmidtiby Aug 8, 2025
de1753f
Code cleanup
henrikmidtiby Aug 8, 2025
69486d8
Use the right version from the merge
henrikmidtiby Aug 8, 2025
9864cd3
Merge branch 'main' into TypingTextMobject
behackl Aug 9, 2025
7d20561
Suggestions from Chopan50
henrikmidtiby Aug 11, 2025
99192c7
Merge remote-tracking branch 'upstream/main' into TypingTextMobject
henrikmidtiby Aug 11, 2025
2ef82ac
Fixes
henrikmidtiby Aug 11, 2025
9ee37d3
More code simplifications.
henrikmidtiby Aug 11, 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
4 changes: 3 additions & 1 deletion manim/mobject/text/tex_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,9 @@ def fade_all_but(self, index_or_string: int | str, opacity: float = 0.5) -> None
if isinstance(arg, str):
part: VGroup | VMobject | None = self.get_part_by_tex(arg)
if part is None:
raise Exception(f"Could not locate part by provided tex string '{arg}'.")
raise Exception(
f"Could not locate part by provided tex string '{arg}'."
)
elif isinstance(arg, int):
part = self.submobjects[arg]
else:
Expand Down
6 changes: 3 additions & 3 deletions manim/mobject/text/text_mobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,16 +726,16 @@ def _get_settings_from_gradient(
settings = []
args = copy.copy(default_args)
if self.gradient:
colors = color_gradient(self.gradient, len(self.text))
colors: list[ManimColor] = color_gradient(self.gradient, len(self.text))
for i in range(len(self.text)):
args["color"] = colors[i].to_hex()
settings.append(TextSetting(i, i + 1, **args))

for word, gradient in self.t2g.items():
colors = (
color_gradient(gradient, len(word))
if len(gradient) != 1
else len(word) * list(gradient)
if len(list(gradient)) != 1
else len(word) * [ManimColor(gradient)]
)
for start, end in self._find_indexes(word, self.text):
for i in range(start, end):
Expand Down
Loading