11from __future__ import annotations
22
33from abc import ABCMeta
4+ from typing import TypeVar
45
56from manim import config
67from manim .mobject .opengl .opengl_mobject import OpenGLMobject
78from manim .mobject .opengl .opengl_point_cloud_mobject import OpenGLPMobject
8- from manim .mobject .opengl .opengl_three_dimensions import OpenGLSurface
9+ from manim .mobject .opengl .opengl_surface import OpenGLSurface
910from manim .mobject .opengl .opengl_vectorized_mobject import OpenGLVMobject
1011
1112from ...constants import RendererType
1213
1314__all__ = ["ConvertToOpenGL" ]
1415
1516
17+ _Class = TypeVar ("_Class" , bound = type )
18+
19+
1620class ConvertToOpenGL (ABCMeta ):
1721 """Metaclass for swapping (V)Mobject with its OpenGL counterpart at runtime
1822 depending on config.renderer. This metaclass should only need to be inherited
1923 on the lowest order inheritance classes such as Mobject and VMobject.
2024 """
2125
22- _converted_classes = []
26+ _converted_classes : list [ ConvertToOpenGL ] = []
2327
24- def __new__ (mcls , name , bases , namespace ):
28+ def __new__ (
29+ mcls : _Class , name : str , bases : tuple [type , ...], namespace : dict [str , object ]
30+ ) -> _Class : # this would ideally be something like `_Type & OpenGLMobject`, but we don't have intersections yet
2531 if config .renderer == RendererType .OPENGL :
2632 # Must check class names to prevent
2733 # cyclic importing.
@@ -40,6 +46,8 @@ def __new__(mcls, name, bases, namespace):
4046
4147 return super ().__new__ (mcls , name , bases , namespace )
4248
43- def __init__ (cls , name , bases , namespace ):
49+ def __init__ (
50+ cls , name : str , bases : tuple [type , ...], namespace : dict [str , object ]
51+ ) -> None :
4452 super ().__init__ (name , bases , namespace )
4553 cls ._converted_classes .append (cls )
0 commit comments