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

Code before:
                    + f"'{arg}' cannot be both '{left}' and '{right}'."
                )
            setattr(right_setting, arg, left if left != default else right)
        return new_setting

    def _get_settings_from_t2xs(
        self,
        t2xs: Sequence[tuple[dict[str, str], str]],
        default_args: dict[str, Iterable[str]],
    ) -> list[TextSetting]:
        settings = []
        t2xwords = set(chain(*([*t2x.keys()] for t2x, _ in t2xs)))
        for word in t2xwords:
            setting_args = {
                arg: str(t2x[word]) if word in t2x else default_args[arg]
                # NOTE: when t2x[word] is a ManimColor, str will yield the
                # hex representation
                for t2x, arg in t2xs
            }

            for start, end in self._find_indexes(word, self.text):
                settings.append(TextSetting(start, end, **setting_args))
        return settings

    def _get_settings_from_gradient(
        self, default_args: dict[str, str]
    ) -> Sequence[TextSetting]:
        settings = []
        args = copy.copy(default_args)
        if self.gradient:
            colors = 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():
            if isinstance(gradient, str) or len(gradient) == 1:
                color = gradient if isinstance(gradient, str) else gradient[0]
                gradient = (ManimColor(color), ManimColor(color))
            colors = (
                color_gradient(gradient, len(word))
                if len(gradient) != 1
                else len(word) * list(gradient)
            )
            for start, end in self._find_indexes(word, self.text):
                for i in range(start, end):
                    args["color"] = colors[i - start].to_hex()
                    settings.append(TextSetting(i, i + 1, **args))
        return settings

    def _text2settings(self, color: ParsableManimColor) -> Sequence[TextSetting]:

Review comment (suggestion):
I suggest that the values of `default_args` are typed as `Any`, because they're the arguments passed to `TextSetting`, a class from ManimPango. See its constructor [here](https://github.com/ManimCommunity/ManimPango/blob/9bfbaa71b3b5ae4309077d0c364bc04488b8b068/manimpango/cmanimpango.pyx#L11-L22).

```suggestion
        self, default_args: dict[str, Any]
```

Code after:
            setattr(right_setting, arg, left if left != default else right)
        return new_setting

    def _get_settings_from_t2xs(
        self,
        t2xs: Sequence[tuple[dict[str, str], str]],
        default_args: dict[str, Iterable[str]],
    ) -> list[TextSetting]:
        settings = []
        t2xwords = set(chain(*([*t2x.keys()] for t2x, _ in t2xs)))
        for word in t2xwords:
            setting_args = {
                arg: str(t2x[word]) if word in t2x else default_args[arg]
                # NOTE: when t2x[word] is a ManimColor, str will yield the
                # hex representation
                for t2x, arg in t2xs
            }

            for start, end in self._find_indexes(word, self.text):
                settings.append(TextSetting(start, end, **setting_args))
        return settings

    def _get_settings_from_gradient(
        self, default_args: dict[str, Any]
    ) -> list[TextSetting]:
        settings = []
        args = copy.copy(default_args)
        if self.gradient:
            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))
            for start, end in self._find_indexes(word, self.text):
                for i in range(start, end):
                    args["color"] = colors[i - start].to_hex()
                    settings.append(TextSetting(i, i + 1, **args))
        return settings

    def _text2settings(self, color: ParsableManimColor) -> list[TextSetting]:
        """Converts the texts and styles to a setting for parsing."""
        t2xs: list[tuple[dict[str, str], str]] = [
            (self.t2f, "font"),
            (self.t2s, "slant"),
            (self.t2w, "weight"),
            (self.t2c, "color"),
        ]
        # setting_args requires values to be strings