all members optional be default in struct
this apllies only to the argument in frappy - in the case of all members optional, they are put into the description, not honouring issue 69 Change-Id: I8e9e4d9ef6bd5b9bb2748f3c6116b7094cd9e927
This commit is contained in:
@ -849,7 +849,7 @@ class ImmutableDict(dict):
|
|||||||
class StructOf(DataType):
|
class StructOf(DataType):
|
||||||
"""data structure with named fields
|
"""data structure with named fields
|
||||||
|
|
||||||
:param optional: a list of optional members
|
:param optional: a list of optional members (default None: all members optional)
|
||||||
:param members: names as keys and types as values for all members
|
:param members: names as keys and types as values for all members
|
||||||
"""
|
"""
|
||||||
def __init__(self, optional=None, **members):
|
def __init__(self, optional=None, **members):
|
||||||
@ -857,7 +857,7 @@ class StructOf(DataType):
|
|||||||
self.members = members
|
self.members = members
|
||||||
if not members:
|
if not members:
|
||||||
raise BadValueError('Empty structs are not allowed!')
|
raise BadValueError('Empty structs are not allowed!')
|
||||||
self.optional = list(optional or [])
|
self.optional = list(members) if optional is None else list(optional)
|
||||||
for name, subtype in list(members.items()):
|
for name, subtype in list(members.items()):
|
||||||
if not isinstance(subtype, DataType):
|
if not isinstance(subtype, DataType):
|
||||||
raise ProgrammingError(
|
raise ProgrammingError(
|
||||||
|
Reference in New Issue
Block a user