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:
2021-12-21 09:21:00 +01:00
parent c523e8f84e
commit 245f4f48bf

View File

@ -849,7 +849,7 @@ class ImmutableDict(dict):
class StructOf(DataType):
"""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
"""
def __init__(self, optional=None, **members):
@ -857,7 +857,7 @@ class StructOf(DataType):
self.members = members
if not members:
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()):
if not isinstance(subtype, DataType):
raise ProgrammingError(