Multiple dispatch decorators
Closed this issue · 0 comments
liamhuber commented
The following two should be equivalent
@Worfklow.wrap.as_function_node()
def foo(x):
y = y + 1
return y
and
@Worfklow.wrap.as_function_node
def foo(x):
y = y + 1
return y
But you should, of course, still be able to provide labels (or kwargs, if the decorator takes them) if you want
@Worfklow.wrap.as_function_node("something_other_than_y")
def foo(x):
y = y + 1
return y
And similarly for macros and any other decorators that don't have required arguments -- which is all of them so far.
This should be doable, at least for the macro and function node decorators, by parsing the *args
to see whether it is zero length, or whether it is length 1 but the value is a callable rather than a string, and just decorating directly.