Skip to content

Commit

Permalink
Add @functools.wraps(func) to the wrapper function of @uamethod
Browse files Browse the repository at this point in the history
This way we can decorate a function which is already decorated with
`@uamethod` again and things like `func.__name__` will correctly return
the name of the decorated function and not `wrapper`.
  • Loading branch information
FMeinicke authored and oroulet committed Jul 4, 2024
1 parent c31aca0 commit 2892c7f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions asyncua/common/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from __future__ import annotations

from asyncio import iscoroutinefunction
from functools import wraps
from typing import Any, Iterable, List, Union

import asyncua
Expand Down Expand Up @@ -77,12 +78,14 @@ def uamethod(func):
"""

if iscoroutinefunction(func):
@wraps(func)
async def wrapper(parent, *args):
func_args = _format_call_inputs(parent, *args)
result = await func(*func_args)
return _format_call_outputs(result)

else:
@wraps(func)
def wrapper(parent, *args):
func_args = _format_call_inputs(parent, *args)
result = func(*func_args)
Expand Down

0 comments on commit 2892c7f

Please sign in to comment.