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

Code before:

class Mobject(Container):
    """Mathematical Object: base class for objects that can be displayed on screen.

    There is a compatibility layer that allows for
    getting and setting generic attributes with ``get_*``
    and ``set_*`` methods. See :meth:`set` for more details.

    Attributes
    ----------
    submobjects : List[:class:`Mobject`]
        The contained objects.
    points : :class:`numpy.ndarray`
        The points of the objects.

        .. seealso::

            :class:`~.VMobject`

    """

    animation_overrides: Dict[
        Type["Animation"], Callable[["Mobject"], "Animation"]
    ] = {}

    def __init_subclass__(cls):
        cls.animation_overrides = {}
        cls._add_intrinsic_animation_overrides()

    def __init__(self, color=WHITE, name=None, dim=3, target=None, z_index=0, **kwargs):
        self.color = Color(color)
        self.name = self.__class__.__name__ if name is None else name
        self.dim = dim
        self.target = target
        self.z_index = z_index
        self.point_hash = None
        self.submobjects = []
        self.updaters = []
        self.updating_suspended = False
        self.reset_points()
        self.generate_points()
        self.init_colors()

        # OpenGL data.
        self.data = {}
        self.depth_test = False
        self.is_fixed_in_frame = False
        self.gloss = 0.0
        self.shadow = 0.0
        self.needs_new_bounding_box = True
        self.parents = []

Review comment (suggestion):
I know this automatically gets converted to a classmethod by python, but I'd prefer being explicit about it nonetheless. Also best practice is to forward `**kwargs` on to the parent method, even if `object.__init_subclass__` just errors if it gets keyword arguments.
```suggestion
    @classmethod
    def __init_subclass__(cls, **kwargs):
        super().__init_subclass__(**kwargs)

```

Code after:

class Mobject(Container):
    """Mathematical Object: base class for objects that can be displayed on screen.

    There is a compatibility layer that allows for
    getting and setting generic attributes with ``get_*``
    and ``set_*`` methods. See :meth:`set` for more details.

    Attributes
    ----------
    submobjects : List[:class:`Mobject`]
        The contained objects.
    points : :class:`numpy.ndarray`
        The points of the objects.

        .. seealso::

            :class:`~.VMobject`

    """

    animation_overrides = {}

    @classmethod
    def __init_subclass__(cls, **kwargs):
        super().__init_subclass__(**kwargs)

        cls.animation_overrides: Dict[
            Type["Animation"], Callable[["Mobject"], "Animation"]
        ] = {}
        cls._add_intrinsic_animation_overrides()

    def __init__(self, color=WHITE, name=None, dim=3, target=None, z_index=0, **kwargs):
        self.color = Color(color)
        self.name = self.__class__.__name__ if name is None else name
        self.dim = dim
        self.target = target
        self.z_index = z_index
        self.point_hash = None
        self.submobjects = []
        self.updaters = []
        self.updating_suspended = False
        self.reset_points()
        self.generate_points()
        self.init_colors()

        # OpenGL data.
        self.data = {}
        self.depth_test = False
        self.is_fixed_in_frame = False
        self.gloss = 0.0