Skip to content
Snippets Groups Projects
Commit 95fe7ff7 authored by Ladislav Lhotka's avatar Ladislav Lhotka
Browse files

Add default to {Array,Object}Value constructor.

parent e09b9f2e
No related branches found
No related tags found
No related merge requests found
"""This module contains classes andtype aliases representing instance values."""
from datetime import datetime
from typing import List, Union
from typing import Dict, List, Union
from .typealiases import *
# Local type aliases
......@@ -36,7 +36,7 @@ class StructuredValue:
class ArrayValue(StructuredValue, list):
"""Array values corresponding to YANG lists and leaf-lists."""
def __init__(self, val: List[Value], ts: datetime=None):
def __init__(self, val: List[Value] = [], ts: datetime=None):
StructuredValue.__init__(self, ts)
list.__init__(self, val)
......@@ -47,7 +47,8 @@ class ArrayValue(StructuredValue, list):
class ObjectValue(StructuredValue, dict):
"""Array values corresponding to YANG container."""
def __init__(self, val: Dict[InstanceName, Value], ts: datetime = None):
def __init__(self, val: Dict[InstanceName, Value] = {},
ts: datetime = None):
StructuredValue.__init__(self, ts)
dict.__init__(self, val)
......
......@@ -228,7 +228,7 @@ class InternalNode(SchemaNode):
def default_value(self) -> Optional[ObjectValue]:
"""Return the receiver's default content."""
res = ObjectValue({})
res = ObjectValue()
for c in self.default_children:
dflt = c.default_value()
if dflt is not None:
......@@ -355,7 +355,7 @@ class InternalNode(SchemaNode):
:param val: raw dictionary
"""
res = ObjectValue({})
res = ObjectValue()
for qn in val:
cn = self.iname2qname(qn)
ch = self.get_data_child(*cn)
......@@ -483,7 +483,7 @@ class SequenceNode(DataNode):
:param val: raw array
"""
res = ArrayValue([])
res = ArrayValue()
for en in val:
res.append(self.entry_from_raw(en))
return res
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment