From f4e5e3850c9a030e0125a908dc5a8dbbcd6659dd Mon Sep 17 00:00:00 2001 From: Xithrius Date: Wed, 1 Sep 2021 18:32:55 -0700 Subject: Union item with None to Optional with item. --- bot/utils/decorators.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bot/utils/decorators.py') 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() -- cgit v1.2.3