refactor : BaseFactory 基类类型自动推导 + 移除冗余代码
- _validate_component 从 BaseFactory[T] 泛型参数自动解析基类类型,9 个子类覆写移除 - Registry 类内联到 BaseFactory._entries,移除未用的 list_by_category/list_by_priority - _component_base 在 __init_subclass__ 时立即解析 - 数据集 4 个子类冗余 __init__ 移除
This commit is contained in:
@@ -30,10 +30,7 @@ class StoreWriter(ABC):
|
||||
|
||||
|
||||
class StoreWriterFactory(BaseFactory["StoreWriter"]):
|
||||
@classmethod
|
||||
def _validate_component(cls, component_cls: type):
|
||||
if not issubclass(component_cls, StoreWriter):
|
||||
raise TypeError(f"{component_cls.__name__} must inherit from StoreWriter")
|
||||
pass
|
||||
|
||||
|
||||
@StoreWriterFactory.register("bin")
|
||||
|
||||
Reference in New Issue
Block a user