diff --git a/chanfig/nested_dict.py b/chanfig/nested_dict.py index 66bceca1..f68c4ac3 100644 --- a/chanfig/nested_dict.py +++ b/chanfig/nested_dict.py @@ -155,14 +155,16 @@ def __init__( self, *args: Any, default_factory: Callable | None = None, - convert_mapping: bool = False, - fallback: bool = False, + convert_mapping: bool | None = None, + fallback: bool | None = None, **kwargs: Any, ) -> None: super().__init__(default_factory) self.merge(*args, **kwargs) - self.setattr("convert_mapping", convert_mapping) - self.setattr("fallback", fallback) + if convert_mapping is not None: + self.setattr("convert_mapping", convert_mapping) + if fallback is not None: + self.setattr("fallback", fallback) def all_keys(self) -> Generator: r""" diff --git a/chanfig/registry.py b/chanfig/registry.py index e912e331..c630fd2b 100644 --- a/chanfig/registry.py +++ b/chanfig/registry.py @@ -88,9 +88,10 @@ class Registry(NestedDict): # type: ignore override: bool = False - def __init__(self, override: bool = False, fallback: bool = False): + def __init__(self, override: bool | None = None, fallback: bool | None = None): super().__init__(fallback=fallback) - self.setattr("override", override) + if override is not None: + self.setattr("override", override) def register(self, component: Any = None, name: Any | None = None) -> Callable: r"""