aboutsummaryrefslogtreecommitdiffstats
path: root/bot/utils/decorators.py
diff options
context:
space:
mode:
authorGravatar Xithrius <[email protected]>2021-09-01 18:32:55 -0700
committerGravatar Xithrius <[email protected]>2021-09-01 18:32:55 -0700
commitf4e5e3850c9a030e0125a908dc5a8dbbcd6659dd (patch)
treeb92170615ddc59ba2571c01030fa9319001d9e93 /bot/utils/decorators.py
parentFix type annotations (diff)
Union item with None to Optional with item.
Diffstat (limited to 'bot/utils/decorators.py')
-rw-r--r--bot/utils/decorators.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/bot/utils/decorators.py b/bot/utils/decorators.py
index 2612ff81..132aaa87 100644
--- a/bot/utils/decorators.py
+++ b/bot/utils/decorators.py
@@ -5,7 +5,7 @@ import random
from asyncio import Lock
from collections.abc import Container
from functools import wraps
-from typing import Callable, Union
+from typing import Callable, Optional, Union
from weakref import WeakValueDictionary
from discord import Colour, Embed
@@ -297,7 +297,7 @@ def whitelist_override(bypass_defaults: bool = False, **kwargs: Container[int])
return inner
-def locked() -> Union[Callable, None]:
+def locked() -> Optional[Callable]:
"""
Allows the user to only run one instance of the decorated command at a time.
@@ -305,11 +305,11 @@ def locked() -> Union[Callable, None]:
This decorator has to go before (below) the `command` decorator.
"""
- def wrap(func: Callable) -> Union[Callable, None]:
+ def wrap(func: Callable) -> Optional[Callable]:
func.__locks = WeakValueDictionary()
@wraps(func)
- async def inner(self: Callable, ctx: Context, *args, **kwargs) -> Union[Callable, None]:
+ async def inner(self: Callable, ctx: Context, *args, **kwargs) -> Optional[Callable]:
lock = func.__locks.setdefault(ctx.author.id, Lock())
if lock.locked():
embed = Embed()