As a last-minute modification, I’m considering adding arbitrary arguments to create_instance
.
# Before
instance = context.create_instance(name="MyInstance")
instance.set_data("family", "myFamily")
# After
instance = context.create_instance(name="MyInstance", family="myFamily")
Where name
is a first positional, required argument, and everything after are arbitrary keyword arguments.
def create_instance(name, **kwargs):
instance = Instance(name)
for key, value in kwargs.items():
instance.set_data(key, value)
Allowing us to do things a bit more succinctly and flexibly.
instance = context.create_instance(
name="MyInstance",
family="myFamily",
data1="more",
data2="even more")
It’s a non-breaking change, but would be difficult to turn back from. Considering 1.1 is a large adjustment already, I’d say we’d either implement it now or at 2.0.
Thoughts?