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

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

henrikmidtiby
Copy link
Contributor

Overview: What does this pull request change?

Reviewer Checklist

  • The PR title is descriptive enough for the changelog, and the PR is labeled correctly
  • If applicable: newly added non-private functions and classes have a docstring including a short summary and a PARAMETERS section
  • If applicable: newly added functions and classes are tested

@@ -120,7 +120,7 @@
self.should_center = should_center
self.svg_height = height
self.svg_width = width
self.color = color
self.color = ManimColor(color)

Check warning

Code scanning / CodeQL

Overwriting attribute in super-class or sub-class Warning

Assignment overwrites attribute color, which was previously defined in superclass
Mobject
.
@@ -110,6 +120,7 @@
else:
mobject_without_dots.add(*(k for k in mobject if k.__class__ != Dot))
if iscode:
assert isinstance(code, Code)

Check failure

Code scanning / CodeQL

Potentially uninitialized local variable Error

Local variable 'code' may be used before it is initialized.
Comment on lines -647 to -673
@deprecated(
since="v0.14.0",
until="v0.15.0",
message="This was internal function, you shouldn't be using it anyway.",
)
def _set_color_by_t2c(self, t2c=None):
"""Sets color for specified strings."""
t2c = t2c if t2c else self.t2c
for word, color in list(t2c.items()):
for start, end in self._find_indexes(word, self.text):
self.chars[start:end].set_color(color)

@deprecated(
since="v0.14.0",
until="v0.15.0",
message="This was internal function, you shouldn't be using it anyway.",
)
def _set_color_by_t2g(self, t2g=None):
"""Sets gradient colors for specified
strings. Behaves similarly to ``set_color_by_t2c``.
"""
t2g = t2g if t2g else self.t2g
for word, gradient in list(t2g.items()):
for start, end in self._find_indexes(word, self.text):
self.chars[start:end].set_color_by_gradient(*gradient)

def _text2hash(self, color: ManimColor):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed this part of the code that was marked as deprecated.

@henrikmidtiby henrikmidtiby marked this pull request as ready for review August 8, 2025 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

Successfully merging this pull request may close these issues.

2 participants