@@ -49,7 +49,8 @@ def fill_converters(gdt_all_in_one: GodotInOne):
4949 if not cls_data .enums :
5050 continue
5151 cls_name = cls_data .name
52- enum_cls_name = f"{ cls_name } Enum"
52+ # enum_cls_name = f"{cls_name}Enum"
53+ enum_cls_name = cls_name
5354
5455 for enum_data in cls_data .enums :
5556 for v in enum_data .values or []:
@@ -201,14 +202,13 @@ def gen_typings_pyi_writers(gdt_all_in_one: GodotInOne):
201202 writer_v = Writer ()
202203 writer_v .write (
203204 """\
204- import typing
205- from typing import overload
205+ from typing import overload, Literal, Any
206206from .enums import *
207207from .classes._Object import Object
208208from . import alias
209209
210210intptr = int
211- def default(gdt_expr: str) -> typing. Any: ...
211+ def default(gdt_expr: str) -> Any: ...
212212
213213"""
214214 )
@@ -245,38 +245,18 @@ def default(gdt_expr: str) -> typing.Any: ...
245245 writer = Writer ()
246246 writer .write (
247247 """\
248- import typing
248+ from typing import Literal, Callable as typing_Callable
249249from ._init import *
250250
251251"""
252252 )
253253 all_writers [f"classes/_{ class_name } .pyi" ] = writer
254254
255- # 获取 xxxEnum
256- class_enum_name = None
257- found_enum_records = converters .find_records (
258- converters .CLASS_ENUM_DATA ,
259- {"cls_name" : clazz .name },
260- )
261- if found_enum_records .shape [0 ] > 0 :
262- class_enum_name = found_enum_records .iloc [0 ]["cls_enum_name" ]
263-
264- # 组装 (xxx, xxxEnum)
265- inherts = []
266- if super_class_name is not None :
267- inherts .append (super_class_name )
268- if class_enum_name is not None :
269- inherts .append (class_enum_name )
270-
271- inhert_str = None
272- if inherts != []:
273- inhert_str = ", " .join (inherts )
274-
275- # 组装 class xxx(xxx, xxxEnum)
276- if inhert_str is not None :
277- writer .writefmt ("class {0}{1}:" ,
255+ # 组装 class xxx(xxx)
256+ if super_class_name :
257+ writer .writefmt ("class {0}({1}):" ,
278258 class_name ,
279- f"( { inhert_str } )"
259+ super_class_name ,
280260 )
281261 else :
282262 writer .writefmt ("class {0}:" ,
@@ -285,6 +265,14 @@ def default(gdt_expr: str) -> typing.Any: ...
285265
286266 writer .indent ()
287267
268+ # 填充 enum
269+ if clazz .enums :
270+ for enum_data in clazz .enums :
271+ if isinstance (enum_data , ClassesEnum ):
272+ enum .gen_class_enum (writer , enum_data )
273+ else :
274+ enum .gen_builtin_class_enum (writer , enum_data )
275+
288276 # ------init
289277 if isinstance (clazz , BuiltinClass ):
290278 if clazz .constructors :
@@ -366,7 +354,7 @@ def default(gdt_expr: str) -> typing.Any: ...
366354 arg_expr_list .append (arg_type )
367355
368356 writer .writefmt (
369- "{0}: Signal[typing.Callable [[{1}], None]] # {2}" ,
357+ "{0}: Signal[typing_Callable [[{1}], None]] # {2}" ,
370358 signal_name ,
371359 ", " .join (arg_expr_list ),
372360 (
@@ -590,28 +578,6 @@ def gen_enums_pyi_writer(gdt_all_in_one: GodotInOne, pyi_writer: Writer) -> Writ
590578 )
591579 # --- global enum ---
592580 enum .gen_global_enums (pyi_writer , gdt_all_in_one .global_enums )
593-
594- # --- classes enum ---
595- enums_w = pyi_writer
596-
597- for cls_data in gdt_all_in_one .classes + gdt_all_in_one .builtin_classes :
598- if not cls_data .enums :
599- continue
600- cls_name = cls_data .name
601- enum_cls_name = f"{ cls_name } Enum"
602- enums_w .write (f"class { enum_cls_name } :" )
603- enums_w .indent ()
604-
605- for enum_data in cls_data .enums :
606-
607- if isinstance (enum_data , ClassesEnum ):
608- enum .gen_class_enum (enums_w , enum_data )
609- else :
610- enum .gen_builtin_class_enum (enums_w , enum_data )
611-
612- enums_w .dedent ()
613- enums_w .write ("\n " )
614-
615581 return pyi_writer
616582
617583
0 commit comments