Repository: ManimCommunity/manim
File: manim/mobject/svg/brace.py (Python)

Code before:
    def shift_brace(self, obj: Mobject, **kwargs: Any) -> Self:
        if isinstance(obj, list):
            obj = self.get_group_class()(*obj)
        self.brace = Brace(obj, self.brace_direction, **kwargs)
        self.brace.put_at_tip(self.label)
        return self

    # TODO: This method is only called from the method change_brace_label, which is
    # not called from any location in the current codebase.
    def change_label(self, *text: str, **kwargs: Any) -> Self:
        self.label = self.label_constructor(*text, **kwargs)

        self.brace.put_at_tip(self.label)
        return self

    # TODO: This method is not called from anywhere in the codebase.
    def change_brace_label(self, obj: Mobject, *text: str, **kwargs: Any) -> Self:
        self.shift_brace(obj)
        self.change_label(*text, **kwargs)
        return self


class BraceText(BraceLabel):
    def __init__(
        self, obj: Mobject, text: str, label_constructor: type[Tex] = Tex, **kwargs: Any
    ):
        super().__init__(obj, text, label_constructor=label_constructor, **kwargs)


class BraceBetweenPoints(Brace):
    """Similar to Brace, but instead of taking a mobject it uses 2
    points to place the brace.

    A fitting direction for the brace is
    computed, but it still can be manually overridden.
    If the points go from left to right, the brace is drawn from below.
    Swapping the points places the brace on the opposite side.

    Parameters
    ----------
    point_1 :
        The first point.
    point_2 :
        The second point.
    direction :
        The direction from which the brace faces towards the points.

    Examples
    --------
        .. manim:: BraceBPExample


Review comment (suggestion):
Same as before:
```suggestion
    def __init__(
        self,
        obj: Mobject,
        text: str,
        label_constructor: type[SingleStringMathTex | Text] = Tex,
        **kwargs: Any,
    ):
```

Code after:
        return self

    def change_label(self, *text: str, **kwargs: Any) -> Self:
        self.label = self.label_constructor(*text, **kwargs)  # type: ignore[arg-type]
        self.brace.put_at_tip(self.label)
        return self

    def change_brace_label(self, obj: Mobject, *text: str, **kwargs: Any) -> Self:
        self.shift_brace(obj)
        self.change_label(*text, **kwargs)
        return self


class BraceText(BraceLabel):
    def __init__(
        self,
        obj: Mobject,
        text: str,
        label_constructor: type[SingleStringMathTex | Text] = Text,
        **kwargs: Any,
    ):
        super().__init__(obj, text, label_constructor=label_constructor, **kwargs)


class BraceBetweenPoints(Brace):
    """Similar to Brace, but instead of taking a mobject it uses 2
    points to place the brace.

    A fitting direction for the brace is
    computed, but it still can be manually overridden.
    If the points go from left to right, the brace is drawn from below.
    Swapping the points places the brace on the opposite side.

    Parameters
    ----------
    point_1 :
        The first point.
    point_2 :
        The second point.
    direction :
        The direction from which the brace faces towards the points.

    Examples
    --------
        .. manim:: BraceBPExample

            class BraceBPExample(Scene):
                def construct(self):
                    p1 = [0,0,0]
                    p2 = [1,2,0]
                    brace = BraceBetweenPoints(p1,p2)