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"""