From e97c5fe82ae884717342a96724a656679f70f3f3 Mon Sep 17 00:00:00 2001 From: Mykyta Poturai Date: Mon, 4 Mar 2024 11:59:01 +0200 Subject: [PATCH] Add list support to _YamlDefaultValue class Currently moulin crashes when it tries to check if the default value is a list. Add support for storing lists to the _YamlDefaultValue. Signed-off-by: Mykyta Poturai --- moulin/yaml_wrapper.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/moulin/yaml_wrapper.py b/moulin/yaml_wrapper.py index 30ae99c..0468fd4 100644 --- a/moulin/yaml_wrapper.py +++ b/moulin/yaml_wrapper.py @@ -18,10 +18,10 @@ class _YamlDefaultValue: """ Helper class that have the same API as YamlValue, but is - constructed from a primitive type. It is used to provide default + constructed from a builtin type. It is used to provide default value in YamlValue.get() method """ - def __init__(self, val: Union[bool, str, int, float, None]): + def __init__(self, val: Union[bool, str, int, float, List, None]): self._val = val def __bool__(self): @@ -55,6 +55,11 @@ def as_float(self) -> float: raise TypeError("Expected float value") return self._val + @property + def is_list(self) -> bool: + """Check if this node represents a list""" + return isinstance(self._val, list) + class YamlValue: # pylint: disable=too-few-public-methods """Wrapper for yaml.Node class. It provides type-safe access to YAML nodes"""