Skip to content

Commit

Permalink
confighelper: store deep copies of parsed options
Browse files Browse the repository at this point in the history
Signed-off-by:  Eric Callahan <[email protected]>
  • Loading branch information
Arksine committed May 14, 2024
1 parent ba94285 commit 9c6048a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions moonraker/confighelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9c6048a

Please sign in to comment.