diff options
| author | 2020-12-18 21:41:30 +0100 | |
|---|---|---|
| committer | 2021-01-09 20:11:15 +0100 | |
| commit | 7134c10485d2b4215213c1ffb670fa9a06d5de1e (patch) | |
| tree | 27a1ec8a6c0ba6b6b55219224f32f63662f44d60 | |
| parent | Return the fetched inventory in the Inventory converter (diff) | |
Use update_wrapper instead of wraps
We're not using it as a decorator so using wraps only complicates
the call syntax
| -rw-r--r-- | bot/decorators.py | 6 | ||||
| -rw-r--r-- | bot/utils/lock.py | 5 |
2 files changed, 5 insertions, 6 deletions
diff --git a/bot/decorators.py b/bot/decorators.py index 3892e350f..a37996e80 100644 --- a/bot/decorators.py +++ b/bot/decorators.py @@ -2,7 +2,7 @@ import asyncio import logging import typing as t from contextlib import suppress -from functools import wraps +from functools import update_wrapper from discord import Member, NotFound from discord.ext import commands @@ -105,7 +105,7 @@ def redirect_output(destination_channel: int, bypass_roles: t.Container[int] = N await ctx.message.delete() log.trace("Redirect output: Deleted invocation message") - return wraps(func)(function.update_wrapper_globals(inner, func)) + return update_wrapper(function.update_wrapper_globals(inner, func), func) return wrap @@ -149,5 +149,5 @@ def respect_role_hierarchy(member_arg: function.Argument) -> t.Callable: else: log.trace(f"{func.__name__}: {target.top_role=} < {actor.top_role=}; calling func") await func(*args, **kwargs) - return wraps(func)(function.update_wrapper_globals(wrapper, func)) + return update_wrapper(function.update_wrapper_globals(wrapper, func), func) return decorator diff --git a/bot/utils/lock.py b/bot/utils/lock.py index cf87321c5..02188c827 100644 --- a/bot/utils/lock.py +++ b/bot/utils/lock.py @@ -1,7 +1,7 @@ import inspect import logging from collections import defaultdict -from functools import partial, wraps +from functools import partial, update_wrapper from typing import Any, Awaitable, Callable, Hashable, Union from weakref import WeakValueDictionary @@ -91,8 +91,7 @@ def lock(namespace: Hashable, resource_id: ResourceId, *, raise_error: bool = Fa log.info(f"{name}: aborted because resource {namespace!r}:{id_!r} is locked") if raise_error: raise LockedResourceError(str(namespace), id_) - - return wraps(func)(function.update_wrapper_globals(wrapper, func)) + return update_wrapper(function.update_wrapper_globals(wrapper, func), func) return decorator |