From e7d90011b1bf1583a6d7d61c9d67f8b3a6573335 Mon Sep 17 00:00:00 2001 From: Zhiyuan Chen Date: Wed, 17 May 2023 19:08:45 +0800 Subject: [PATCH] support args and kwargs in apply Signed-off-by: Zhiyuan Chen --- chanfig/nested_dict.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chanfig/nested_dict.py b/chanfig/nested_dict.py index 1f653d88..c3636829 100644 --- a/chanfig/nested_dict.py +++ b/chanfig/nested_dict.py @@ -171,7 +171,7 @@ def all_items(self, prefix=""): return all_items(self) - def apply(self, func: Callable) -> NestedDict: + def apply(self, func: Callable, *args, **kwargs) -> NestedDict: r""" Recursively apply a function to `NestedDict` and its children. @@ -189,8 +189,8 @@ def apply(self, func: Callable) -> NestedDict: for value in self.values(): if isinstance(value, NestedDict): - value.apply(func) - return func(self) or self + value.apply(func, *args, **kwargs) + return func(self, *args, **kwargs) or self def get(self, name: Any, default: Any = Null) -> Any: r"""