From 678252263f024b3b3c236b3df6f03050b1e34f24 Mon Sep 17 00:00:00 2001 From: Zhiyuan Chen Date: Sun, 25 Aug 2024 15:00:38 +0800 Subject: [PATCH] return `default` if Registry.lookup finds a Registry Signed-off-by: Zhiyuan Chen --- chanfig/registry.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/chanfig/registry.py b/chanfig/registry.py index 1d76341b..7f30c5d8 100644 --- a/chanfig/registry.py +++ b/chanfig/registry.py @@ -201,7 +201,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