Skip to content

Commit ded0231

Browse files
properties: Allow saving of instance attributes even if they are not call arguments.
1 parent bce160a commit ded0231

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

labscript.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,20 @@ def new_function(inst, *args, **kwargs):
161161
return_value = func(inst, *args, **kwargs)
162162

163163
# Get a dict of the call arguments/keyword arguments by name:
164-
property_values = getcallargs(func, inst, *args, **kwargs)
165-
166-
# Overwrite with instance attributes of the same name, if they exist:
167-
for name, value in property_values.items():
168-
property_values[name] = getattr(inst, name, value)
164+
call_values = getcallargs(func, inst, *args, **kwargs)
165+
166+
all_property_names = set()
167+
for names in property_names.values():
168+
all_property_names.update(names)
169+
170+
property_values = {}
171+
for name in all_property_names:
172+
# If there is an instance attribute with that name, use that, otherwise
173+
# use the call value:
174+
if hasattr(inst, name):
175+
property_values[name] = getattr(inst, name)
176+
else:
177+
property_values[name] = call_values[name]
169178

170179
# Save them:
171180
inst.set_properties(property_values, property_names)

0 commit comments

Comments
 (0)