phenotypic.tools_.register.BaseRegistry#
- class phenotypic.tools_.register.BaseRegistry[source]
Bases:
Generic[T]Base class for component registries.
Subclasses define _REGISTRY dict and implement register/get/available. Registered classes may define a
call_nameclass attribute; if not set, the class name is used as the default.Examples
Create a custom registry:
class MyComponentRegistry(BaseRegistry["MyComponent"]): _REGISTRY: ClassVar[dict[str, type["MyComponent"]]] = {} _registry_name: ClassVar[str] = "component" @MyComponentRegistry.register class ConcreteComponent: call_name = "concrete" # Look up by name cls = MyComponentRegistry.get("concrete")
Methods
__init__Return names of all registered components.
Look up registered class by name.
Decorator that registers a class by its
call_nameclass attribute.- classmethod register(target_cls: type[T]) type[T][source]
Decorator that registers a class by its
call_nameclass attribute.If
call_nameis not defined on the class, defaults to the class name.- Parameters:
target_cls (type[T]) – The class to register.
- Returns:
The registered class (unchanged).
- Raises:
ValueError – If a component with the same name is already registered.
- Return type:
type[T]