Skip to content

Commit

Permalink
Add is_list property to _YamlDefaultValue class
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Deedone committed Mar 4, 2024
1 parent 6fb1737 commit 7723966
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions moulin/yaml_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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"""
Expand Down

0 comments on commit 7723966

Please sign in to comment.