Skip to content

Commit b80c933

Browse files
committed
update
1 parent e93966f commit b80c933

1 file changed

Lines changed: 20 additions & 16 deletions

File tree

cozeloop/decorator/decorator.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,11 @@ def sync_wrapper(*args: Any, **kwargs: Any):
344344
if len(args) > 0 and is_class_func(func):
345345
extra = {"_inner_class_self": args[0]}
346346
args = args[1:]
347-
inp = {
348-
"args": args,
349-
"kwargs": kwargs
350-
}
347+
inp = {}
348+
if len(args) > 0:
349+
inp['args'] = args
350+
if len(kwargs) > 0:
351+
inp['kwargs'] = kwargs
351352
res = RunnableLambda(_param_wrapped_func).invoke(input=inp, config=config, **extra)
352353
if hasattr(res, "__iter__"):
353354
return res
@@ -369,10 +370,11 @@ async def async_wrapper(*args: Any, **kwargs: Any):
369370
if len(args) > 0 and is_class_func(func):
370371
extra = {"_inner_class_self": args[0]}
371372
args = args[1:]
372-
inp = {
373-
"args": args,
374-
"kwargs": kwargs
375-
}
373+
inp = {}
374+
if len(args) > 0:
375+
inp['args'] = args
376+
if len(kwargs) > 0:
377+
inp['kwargs'] = kwargs
376378
res = await RunnableLambda(_param_wrapped_func_async).ainvoke(input=inp, config=config, **extra)
377379
if hasattr(res, "__aiter__"):
378380
return res
@@ -398,10 +400,11 @@ def gen_wrapper(*args: Any, **kwargs: Any):
398400
if len(args) > 0 and is_class_func(func):
399401
extra = {"_inner_class_self": args[0]}
400402
args = args[1:]
401-
inp = {
402-
"args": args,
403-
"kwargs": kwargs
404-
}
403+
inp = {}
404+
if len(args) > 0:
405+
inp['args'] = args
406+
if len(kwargs) > 0:
407+
inp['kwargs'] = kwargs
405408
gen = RunnableLambda(_param_wrapped_func).invoke(input=inp, config=config, *extra)
406409
try:
407410
for item in gen:
@@ -420,10 +423,11 @@ async def async_gen_wrapper(*args: Any, **kwargs: Any):
420423
if len(args) > 0 and is_class_func(func):
421424
extra = {"_inner_class_self": args[0]}
422425
args = args[1:]
423-
inp = {
424-
"args": args,
425-
"kwargs": kwargs
426-
}
426+
inp = {}
427+
if len(args) > 0:
428+
inp['args'] = args
429+
if len(kwargs) > 0:
430+
inp['kwargs'] = kwargs
427431
gen = RunnableLambda(_param_wrapped_func_async).invoke(input=inp, config=config, **extra)
428432
items = []
429433
try:

0 commit comments

Comments
 (0)