fix(core): Fix incorrect type hints. (#5427)

This commit is contained in:
-LAN-
2024-06-20 15:16:21 +08:00
committed by GitHub
parent e4259a8f13
commit 23fa3dedc4
11 changed files with 166 additions and 117 deletions

View File

@@ -1,5 +1,5 @@
import enum
import importlib
import importlib.util
import json
import logging
import os
@@ -74,6 +74,8 @@ class Extensible:
# Dynamic loading {subdir_name}.py file and find the subclass of Extensible
py_path = os.path.join(subdir_path, extension_name + '.py')
spec = importlib.util.spec_from_file_location(extension_name, py_path)
if not spec or not spec.loader:
raise Exception(f"Failed to load module {extension_name} from {py_path}")
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
@@ -108,6 +110,6 @@ class Extensible:
position=position
))
sorted_extensions = sort_to_dict_by_position_map(position_map, extensions, lambda x: x.name)
sorted_extensions = sort_to_dict_by_position_map(position_map=position_map, data=extensions, name_func=lambda x: x.name)
return sorted_extensions