Repository: ManimCommunity/manim
File: manim/mobject/text/tex_mobject.py (Python)

Code before:
                return tex1 == tex2

        return VGroup(*(m for m in self.submobjects if test(tex, m.get_tex_string())))

    def get_part_by_tex(self, tex, **kwargs):
        all_parts = self.get_parts_by_tex(tex, **kwargs)
        return all_parts[0] if all_parts else None

    def set_color_by_tex(self, tex, color, **kwargs):
        parts_to_color = self.get_parts_by_tex(tex, **kwargs)
        for part in parts_to_color:
            part.set_color(color)
        return self

    def set_opacity_by_tex(self, tex, opacity=0.5, remaining_opacity=None, **kwargs):
        """
        Sets the opacity of the tex specified. If 'remaining_opacity' is specified,
        then the remaining tex will be set to that opacity.

        Parameters
        ----------
        tex : str
            The tex to set the opacity of.
        opacity : float, optional
            Default 0.5. The opacity to set the tex to
        remaining_opacity : float, optional
            Default None. The opacity to set the remaining tex to.
            If None, then the remaining tex will not be changed
        """
        part_index = self.index_of_part_by_tex(tex)
        for i, part in enumerate(self):
            if i == part_index:
                part.set_opacity(opacity)
            elif remaining_opacity is not None:
                part.set_opacity(remaining_opacity)
        return self

    def set_color_by_tex_to_color_map(self, texs_to_color_map, **kwargs):
        for texs, color in list(texs_to_color_map.items()):
            try:
                # If the given key behaves like tex_strings
                texs + ""
                self.set_color_by_tex(texs, color, **kwargs)
            except TypeError:
                # If the given key is a tuple
                for tex in texs:
                    self.set_color_by_tex(tex, color, **kwargs)
        return self

    def index_of_part(self, part):
        split_self = self.split()

Review comment (suggestion):
The type hints should be moved from the docstring to the method head: `tex` -> `tex: str`, `opacity` -> `opacity: float = 0.5`, etc.


```suggestion
        tex
            The tex to set the opacity of.
        opacity
            Default 0.5. The opacity to set the tex to
        remaining_opacity
```

Code after:
                return tex1 == tex2

        return VGroup(*(m for m in self.submobjects if test(tex, m.get_tex_string())))

    def get_part_by_tex(self, tex, **kwargs):
        all_parts = self.get_parts_by_tex(tex, **kwargs)
        return all_parts[0] if all_parts else None

    def set_color_by_tex(self, tex, color, **kwargs):
        parts_to_color = self.get_parts_by_tex(tex, **kwargs)
        for part in parts_to_color:
            part.set_color(color)
        return self

    def set_opacity_by_tex(
        self, tex: str, opacity: float = 0.5, remaining_opacity: float = None, **kwargs
    ):
        """
        Sets the opacity of the tex specified. If 'remaining_opacity' is specified,
        then the remaining tex will be set to that opacity.

        Parameters
        ----------
        tex
            The tex to set the opacity of.
        opacity
            Default 0.5. The opacity to set the tex to
        remaining_opacity
            Default None. The opacity to set the remaining tex to.
            If None, then the remaining tex will not be changed
        """
        if remaining_opacity is not None:
            self.set_opacity(opacity=remaining_opacity)
        for part in self.get_parts_by_tex(tex):
            part.set_opacity(opacity)
        return self

    def set_color_by_tex_to_color_map(self, texs_to_color_map, **kwargs):
        for texs, color in list(texs_to_color_map.items()):
            try:
                # If the given key behaves like tex_strings
                texs + ""
                self.set_color_by_tex(texs, color, **kwargs)
            except TypeError:
                # If the given key is a tuple
                for tex in texs:
                    self.set_color_by_tex(tex, color, **kwargs)
        return self

    def index_of_part(self, part):
        split_self = self.split()