From 9c6048a75994dca29e65e691e6dd9ec0e20d9e66 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Tue, 14 May 2024 18:05:19 -0400 Subject: [PATCH] confighelper: store deep copies of parsed options Signed-off-by: Eric Callahan --- moonraker/confighelper.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/moonraker/confighelper.py b/moonraker/confighelper.py index 7ccd67498..c0da88875 100644 --- a/moonraker/confighelper.py +++ b/moonraker/confighelper.py @@ -123,7 +123,7 @@ def getsection( ) def _get_option(self, - func: Callable[..., Any], + func: Callable[..., _T], option: str, default: Union[Sentinel, _T], above: Optional[Union[int, float]] = None, @@ -167,13 +167,14 @@ def _get_option(self, f"to section [{self.section}]. Please correct your " f"configuration, see {help} for detailed documentation." ) - self._check_option(option, val, above, below, minval, maxval) + if isinstance(val, (int, float)): + self._check_option(option, val, above, below, minval, maxval) if option not in self.parsed[section]: if ( val is None or isinstance(val, (int, float, bool, str, dict, list)) ): - self.parsed[section][option] = val + self.parsed[section][option] = copy.deepcopy(val) else: # If the item cannot be encoded to json serialize to a string self.parsed[section][option] = str(val)