diff --git a/chanfig/registry.py b/chanfig/registry.py index 1d76341b..bfc10747 100644 --- a/chanfig/registry.py +++ b/chanfig/registry.py @@ -108,6 +108,7 @@ def __init__( self.setattr("key", key) if default is not None: self.setattr("default", default) + self.setattr("default_factory", Registry) def register( self, component: Any = Null, name: Any = Null, override: bool = False, default: bool = False @@ -201,7 +202,10 @@ def lookup(self, name: str, default: Any = Null) -> Any: if default is Null: default = self.getattr("default", Null) - return self.get(name, default) + element = self.get(name, default) + if isinstance(element, Registry): + return element.getattr("default") + return element @staticmethod def init(cls: Callable, *args: Any, **kwargs: Any) -> Any: # pylint: disable=W0211