Skip to content

Commit

Permalink
Merge branch 'tickets/DM-35386'
Browse files Browse the repository at this point in the history
  • Loading branch information
natelust committed Jul 6, 2022
2 parents c817b60 + 98e8933 commit cc9029d
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ def items(self) -> Iterable[Tuple[str, ActionTypeVar]]:
for name in self.fieldNames:
yield name, getattr(self, name)

def __bool__(self) -> bool:
return bool(self._attrs)


T = TypeVar("T", bound="ConfigurableActionStructField")

Expand Down Expand Up @@ -274,8 +277,8 @@ def __set__(self, instance: Config,
else:
# An actual value is being assigned check for what it is
if isinstance(value, self.StructClass):
# If this is a ConfigurableActionStruct, we need to make our own
# copy that references this current field
# If this is a ConfigurableActionStruct, we need to make our
# own copy that references this current field
value = self.StructClass(instance, self, value._attrs, at=at, label=label)
elif isinstance(value, (SimpleNamespace, Struct)):
# If this is a a python analogous container, we need to make
Expand Down Expand Up @@ -355,8 +358,11 @@ def toDict(self, instance):
def save(self, outfile, instance):
actionStruct = self.__get__(instance)
fullname = _joinNamePath(instance._name, self.name)

# Ensure that a struct is always empty before assigning to it.
outfile.write(f"{fullname}=None\n")

if actionStruct is None:
outfile.write(u"{}={!r}\n".format(fullname, actionStruct))
return

for v in actionStruct:
Expand Down

0 comments on commit cc9029d

Please sign in to comment.