Repository: ManimCommunity/manim
File: manim/mobject/types/vectorized_mobject.py (Python)

Code before:
        # Match up current rgbas array with the newly calculated
        # one. 99% of the time they'll be the same.
        curr_rgbas = getattr(self, array_name)
        if len(curr_rgbas) < len(rgbas):
            curr_rgbas = stretch_array_to_length(curr_rgbas, len(rgbas))
            setattr(self, array_name, curr_rgbas)
        elif len(rgbas) < len(curr_rgbas):
            rgbas = stretch_array_to_length(rgbas, len(curr_rgbas))
        # Only update rgb if color was not None, and only
        # update alpha channel if opacity was passed in
        if color is not None:
            curr_rgbas[:, :3] = rgbas[:, :3]
        if opacity is not None:
            curr_rgbas[:, 3] = rgbas[:, 3]
        return self

    def set_fill(self, color=None, opacity=None, family=True) -> "VMobject":
        """Set the fill color and fill opacity of a :class:`VMobject`
        including its subMobjects.

        Parameters
        ----------
        color : optional
            Fill color of the :class:`VMobject`.
        opacity : :class:`float`, optional
            Fill opacity of the :class:`VMobject`.

        Returns
        -------
        VMobject
            self. For chaining purposes.

        Examples
        --------
        .. manim:: SetFill
            :save_last_frame:

            class SetFill(Scene):
                def construct(self):
                    square = Square().scale(2).set_fill(WHITE,1)
                    circle1 = Circle().set_fill(GREEN,0.8)
                    circle2 = Circle().set_fill(YELLOW) # No fill_opacity
                    circle3 = Circle().set_fill(color = '#FF2135', opacity = 0.2)
                    group = Group(circle1,circle2,circle3).arrange()
                    self.add(square)
                    self.add(group)

        .. important::
            All Mobjects are initialized with 0 fill_opacity. If you forget to set it, the fill color won't show.

        See Also

Review comment (suggestion):
If you want to add type hints, please add them to the function header (`def set_fill(self, color=None, opacity: float = None, family: bool = True):`). Also, here is a suggestion for a short description for the third parameter:

```suggestion
        color
            Fill color of the :class:`VMobject`.
        opacity
            Fill opacity of the :class:`VMobject`.
        family
            If ``True``, the fill color of all submobjects is also set.
```

Code after:
        # Match up current rgbas array with the newly calculated
        # one. 99% of the time they'll be the same.
        curr_rgbas = getattr(self, array_name)
        if len(curr_rgbas) < len(rgbas):
            curr_rgbas = stretch_array_to_length(curr_rgbas, len(rgbas))
            setattr(self, array_name, curr_rgbas)
        elif len(rgbas) < len(curr_rgbas):
            rgbas = stretch_array_to_length(rgbas, len(curr_rgbas))
        # Only update rgb if color was not None, and only
        # update alpha channel if opacity was passed in
        if color is not None:
            curr_rgbas[:, :3] = rgbas[:, :3]
        if opacity is not None:
            curr_rgbas[:, 3] = rgbas[:, 3]
        return self

    def set_fill(
        self,
        color: Optional[str] = None,
        opacity: Optional[float] = None,
        family: bool = True,
    ) -> "VMobject":
        """Set the fill color and fill opacity of a :class:`VMobject`.

        Parameters
        ----------
        color
            Fill color of the :class:`VMobject`.
        opacity
            Fill opacity of the :class:`VMobject`.
        family
            If ``True``, the fill color of all submobjects is also set.

        Returns
        -------
        VMobject
            self. For chaining purposes.

        Examples
        --------
        .. manim:: SetFill
            :save_last_frame:

            class SetFill(Scene):
                def construct(self):
                    square = Square().scale(2).set_fill(WHITE,1)
                    circle1 = Circle().set_fill(GREEN,0.8)
                    circle2 = Circle().set_fill(YELLOW) # No fill_opacity
                    circle3 = Circle().set_fill(color = '#FF2135', opacity = 0.2)
                    group = Group(circle1,circle2,circle3).arrange()
                    self.add(square)