4
4
5
5
__all__ = ["TransformMatchingShapes" , "TransformMatchingTex" ]
6
6
7
- from typing import TYPE_CHECKING
7
+ from typing import TYPE_CHECKING , Any
8
8
9
9
import numpy as np
10
10
11
11
from manim .mobject .opengl .opengl_mobject import OpenGLGroup , OpenGLMobject
12
12
from manim .mobject .opengl .opengl_vectorized_mobject import OpenGLVGroup , OpenGLVMobject
13
+ from manim .mobject .text .tex_mobject import SingleStringMathTex
13
14
14
15
from .._config import config
15
16
from ..constants import RendererType
@@ -74,10 +75,10 @@ def __init__(
74
75
transform_mismatches : bool = False ,
75
76
fade_transform_mismatches : bool = False ,
76
77
key_map : dict | None = None ,
77
- ** kwargs ,
78
+ ** kwargs : Any ,
78
79
):
79
80
if isinstance (mobject , OpenGLVMobject ):
80
- group_type = OpenGLVGroup
81
+ group_type : type [ OpenGLVGroup | OpenGLGroup | VGroup | Group ] = OpenGLVGroup
81
82
elif isinstance (mobject , OpenGLMobject ):
82
83
group_type = OpenGLGroup
83
84
elif isinstance (mobject , VMobject ):
@@ -141,31 +142,33 @@ def __init__(
141
142
self .to_add = target_mobject
142
143
143
144
def get_shape_map (self , mobject : Mobject ) -> dict :
144
- shape_map = {}
145
+ shape_map : dict [ int | str , VGroup | OpenGLVGroup ] = {}
145
146
for sm in self .get_mobject_parts (mobject ):
146
147
key = self .get_mobject_key (sm )
147
148
if key not in shape_map :
148
149
if config ["renderer" ] == RendererType .OPENGL :
149
150
shape_map [key ] = OpenGLVGroup ()
150
151
else :
151
152
shape_map [key ] = VGroup ()
153
+ # error: Argument 1 to "add" of "OpenGLVGroup" has incompatible type "Mobject"; expected "OpenGLVMobject" [arg-type]
152
154
shape_map [key ].add (sm )
153
155
return shape_map
154
156
155
157
def clean_up_from_scene (self , scene : Scene ) -> None :
156
158
# Interpolate all animations back to 0 to ensure source mobjects remain unchanged.
157
159
for anim in self .animations :
158
160
anim .interpolate (0 )
161
+ # error: Argument 1 to "remove" of "Scene" has incompatible type "OpenGLMobject"; expected "Mobject" [arg-type]
159
162
scene .remove (self .mobject )
160
163
scene .remove (* self .to_remove )
161
164
scene .add (self .to_add )
162
165
163
166
@staticmethod
164
- def get_mobject_parts (mobject : Mobject ):
167
+ def get_mobject_parts (mobject : Mobject ) -> list [ Mobject ] :
165
168
raise NotImplementedError ("To be implemented in subclass." )
166
169
167
170
@staticmethod
168
- def get_mobject_key (mobject : Mobject ):
171
+ def get_mobject_key (mobject : Mobject ) -> int | str :
169
172
raise NotImplementedError ("To be implemented in subclass." )
170
173
171
174
@@ -205,7 +208,7 @@ def __init__(
205
208
transform_mismatches : bool = False ,
206
209
fade_transform_mismatches : bool = False ,
207
210
key_map : dict | None = None ,
208
- ** kwargs ,
211
+ ** kwargs : Any ,
209
212
):
210
213
super ().__init__ (
211
214
mobject ,
@@ -269,7 +272,7 @@ def __init__(
269
272
transform_mismatches : bool = False ,
270
273
fade_transform_mismatches : bool = False ,
271
274
key_map : dict | None = None ,
272
- ** kwargs ,
275
+ ** kwargs : Any ,
273
276
):
274
277
super ().__init__ (
275
278
mobject ,
@@ -294,4 +297,5 @@ def get_mobject_parts(mobject: Mobject) -> list[Mobject]:
294
297
295
298
@staticmethod
296
299
def get_mobject_key (mobject : Mobject ) -> str :
300
+ assert isinstance (mobject , SingleStringMathTex )
297
301
return mobject .tex_string
0 commit comments