From 745cd1d6d3d6227d2a1e82cf25611d76221c40cd Mon Sep 17 00:00:00 2001 From: decorator-factory <42166884+decorator-factory@users.noreply.github.com> Date: Sat, 7 Aug 2021 05:23:03 +0300 Subject: Fix type annotations --- bot/utils/__init__.py | 5 +++-- bot/utils/checks.py | 3 ++- bot/utils/converters.py | 4 ++-- bot/utils/decorators.py | 37 +++++++++++++++++++------------------ bot/utils/extensions.py | 3 ++- bot/utils/pagination.py | 5 +++-- bot/utils/randomization.py | 7 ++++--- 7 files changed, 35 insertions(+), 29 deletions(-) (limited to 'bot/utils') diff --git a/bot/utils/__init__.py b/bot/utils/__init__.py index bef12d25..91682dbc 100644 --- a/bot/utils/__init__.py +++ b/bot/utils/__init__.py @@ -2,8 +2,9 @@ import asyncio import contextlib import re import string +from collections.abc import Iterable from datetime import datetime -from typing import Iterable, List, Optional +from typing import Optional import discord from discord.ext.commands import BadArgument, Context @@ -32,7 +33,7 @@ def resolve_current_month() -> Month: async def disambiguate( ctx: Context, - entries: List[str], + entries: list[str], *, timeout: float = 30, entries_per_page: int = 20, diff --git a/bot/utils/checks.py b/bot/utils/checks.py index 438ec750..d5c06728 100644 --- a/bot/utils/checks.py +++ b/bot/utils/checks.py @@ -1,6 +1,7 @@ import datetime import logging -from typing import Callable, Container, Iterable, Optional +from collections.abc import Container, Iterable +from typing import Callable, Optional from discord.ext.commands import ( BucketType, diff --git a/bot/utils/converters.py b/bot/utils/converters.py index fe2c980c..7227a406 100644 --- a/bot/utils/converters.py +++ b/bot/utils/converters.py @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Tuple, Union +from typing import Union import discord from discord.ext import commands @@ -23,7 +23,7 @@ class CoordinateConverter(commands.Converter): """Converter for Coordinates.""" @staticmethod - async def convert(ctx: commands.Context, coordinate: str) -> Tuple[int, int]: + async def convert(ctx: commands.Context, coordinate: str) -> tuple[int, int]: """Take in a coordinate string and turn it into an (x, y) tuple.""" if len(coordinate) not in (2, 3): raise commands.BadArgument("Invalid co-ordinate provided.") diff --git a/bot/utils/decorators.py b/bot/utils/decorators.py index c0783144..2612ff81 100644 --- a/bot/utils/decorators.py +++ b/bot/utils/decorators.py @@ -2,9 +2,10 @@ import asyncio import functools import logging import random -import typing as t from asyncio import Lock +from collections.abc import Container from functools import wraps +from typing import Callable, Union from weakref import WeakValueDictionary from discord import Colour, Embed @@ -32,7 +33,7 @@ class InMonthCheckFailure(CheckFailure): pass -def seasonal_task(*allowed_months: Month, sleep_time: t.Union[float, int] = ONE_DAY) -> t.Callable: +def seasonal_task(*allowed_months: Month, sleep_time: Union[float, int] = ONE_DAY) -> Callable: """ Perform the decorated method periodically in `allowed_months`. @@ -44,7 +45,7 @@ def seasonal_task(*allowed_months: Month, sleep_time: t.Union[float, int] = ONE_ The wrapped task is responsible for waiting for the bot to be ready, if necessary. """ - def decorator(task_body: t.Callable) -> t.Callable: + def decorator(task_body: Callable) -> Callable: @functools.wraps(task_body) async def decorated_task(*args, **kwargs) -> None: """Call `task_body` once every `sleep_time` seconds in `allowed_months`.""" @@ -63,13 +64,13 @@ def seasonal_task(*allowed_months: Month, sleep_time: t.Union[float, int] = ONE_ return decorator -def in_month_listener(*allowed_months: Month) -> t.Callable: +def in_month_listener(*allowed_months: Month) -> Callable: """ Shield a listener from being invoked outside of `allowed_months`. The check is performed against current UTC month. """ - def decorator(listener: t.Callable) -> t.Callable: + def decorator(listener: Callable) -> Callable: @functools.wraps(listener) async def guarded_listener(*args, **kwargs) -> None: """Wrapped listener will abort if not in allowed month.""" @@ -84,7 +85,7 @@ def in_month_listener(*allowed_months: Month) -> t.Callable: return decorator -def in_month_command(*allowed_months: Month) -> t.Callable: +def in_month_command(*allowed_months: Month) -> Callable: """ Check whether the command was invoked in one of `enabled_months`. @@ -106,7 +107,7 @@ def in_month_command(*allowed_months: Month) -> t.Callable: return commands.check(predicate) -def in_month(*allowed_months: Month) -> t.Callable: +def in_month(*allowed_months: Month) -> Callable: """ Universal decorator for season-locking commands and listeners alike. @@ -124,7 +125,7 @@ def in_month(*allowed_months: Month) -> t.Callable: manually set to True - this causes a circumvention of the group's callback and the seasonal check applied to it. """ - def decorator(callable_: t.Callable) -> t.Callable: + def decorator(callable_: Callable) -> Callable: # Functions decorated as commands are turned into instances of `Command` if isinstance(callable_, Command): logging.debug(f"Command {callable_.qualified_name} will be locked to {human_months(allowed_months)}") @@ -144,7 +145,7 @@ def in_month(*allowed_months: Month) -> t.Callable: return decorator -def with_role(*role_ids: int) -> t.Callable: +def with_role(*role_ids: int) -> Callable: """Check to see whether the invoking user has any of the roles specified in role_ids.""" async def predicate(ctx: Context) -> bool: if not ctx.guild: # Return False in a DM @@ -167,7 +168,7 @@ def with_role(*role_ids: int) -> t.Callable: return commands.check(predicate) -def without_role(*role_ids: int) -> t.Callable: +def without_role(*role_ids: int) -> Callable: """Check whether the invoking user does not have all of the roles specified in role_ids.""" async def predicate(ctx: Context) -> bool: if not ctx.guild: # Return False in a DM @@ -187,7 +188,7 @@ def without_role(*role_ids: int) -> t.Callable: return commands.check(predicate) -def whitelist_check(**default_kwargs: t.Container[int]) -> t.Callable[[Context], bool]: +def whitelist_check(**default_kwargs: Container[int]) -> Callable[[Context], bool]: """ Checks if a message is sent in a whitelisted context. @@ -222,8 +223,8 @@ def whitelist_check(**default_kwargs: t.Container[int]) -> t.Callable[[Context], kwargs[arg] = new_value # Merge containers - elif isinstance(default_value, t.Container): - if isinstance(new_value, t.Container): + elif isinstance(default_value, Container): + if isinstance(new_value, Container): kwargs[arg] = (*default_value, *new_value) else: kwargs[arg] = new_value @@ -279,7 +280,7 @@ def whitelist_check(**default_kwargs: t.Container[int]) -> t.Callable[[Context], return predicate -def whitelist_override(bypass_defaults: bool = False, **kwargs: t.Container[int]) -> t.Callable: +def whitelist_override(bypass_defaults: bool = False, **kwargs: Container[int]) -> Callable: """ Override global whitelist context, with the kwargs specified. @@ -288,7 +289,7 @@ def whitelist_override(bypass_defaults: bool = False, **kwargs: t.Container[int] This decorator has to go before (below) below the `command` decorator. """ - def inner(func: t.Callable) -> t.Callable: + def inner(func: Callable) -> Callable: func.override = kwargs func.override_reset = bypass_defaults return func @@ -296,7 +297,7 @@ def whitelist_override(bypass_defaults: bool = False, **kwargs: t.Container[int] return inner -def locked() -> t.Union[t.Callable, None]: +def locked() -> Union[Callable, None]: """ Allows the user to only run one instance of the decorated command at a time. @@ -304,11 +305,11 @@ def locked() -> t.Union[t.Callable, None]: This decorator has to go before (below) the `command` decorator. """ - def wrap(func: t.Callable) -> t.Union[t.Callable, None]: + def wrap(func: Callable) -> Union[Callable, None]: func.__locks = WeakValueDictionary() @wraps(func) - async def inner(self: t.Callable, ctx: Context, *args, **kwargs) -> t.Union[t.Callable, None]: + async def inner(self: Callable, ctx: Context, *args, **kwargs) -> Union[Callable, None]: lock = func.__locks.setdefault(ctx.author.id, Lock()) if lock.locked(): embed = Embed() diff --git a/bot/utils/extensions.py b/bot/utils/extensions.py index cd491c4b..cbb8f15e 100644 --- a/bot/utils/extensions.py +++ b/bot/utils/extensions.py @@ -1,7 +1,8 @@ import importlib import inspect import pkgutil -from typing import Iterator, NoReturn +from collections.abc import Iterator +from typing import NoReturn from discord.ext.commands import Context diff --git a/bot/utils/pagination.py b/bot/utils/pagination.py index b1062c09..013ef9e7 100644 --- a/bot/utils/pagination.py +++ b/bot/utils/pagination.py @@ -1,6 +1,7 @@ import asyncio import logging -from typing import Iterable, List, Optional, Tuple +from collections.abc import Iterable +from typing import Optional from discord import Embed, Member, Reaction from discord.abc import User @@ -313,7 +314,7 @@ class ImagePaginator(Paginator): self.images.append(image) @classmethod - async def paginate(cls, pages: List[Tuple[str, str]], ctx: Context, embed: Embed, + async def paginate(cls, pages: list[tuple[str, str]], ctx: Context, embed: Embed, prefix: str = "", suffix: str = "", timeout: int = 300, exception_on_empty_embed: bool = False) -> None: """ diff --git a/bot/utils/randomization.py b/bot/utils/randomization.py index 8f47679a..3360ef44 100644 --- a/bot/utils/randomization.py +++ b/bot/utils/randomization.py @@ -1,6 +1,7 @@ import itertools import random -import typing as t +from collections.abc import Iterable +from typing import Any class RandomCycle: @@ -10,11 +11,11 @@ class RandomCycle: The iterable is reshuffled after each full cycle. """ - def __init__(self, iterable: t.Iterable) -> None: + def __init__(self, iterable: Iterable) -> None: self.iterable = list(iterable) self.index = itertools.cycle(range(len(iterable))) - def __next__(self) -> t.Any: + def __next__(self) -> Any: idx = next(self.index) if idx == 0: -- cgit v1.2.3 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/exts/easter/egg_decorating.py | 6 +++--- bot/exts/evergreen/fun.py | 2 +- bot/exts/halloween/spookynamerate.py | 4 ++-- bot/utils/decorators.py | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'bot/utils') diff --git a/bot/exts/easter/egg_decorating.py b/bot/exts/easter/egg_decorating.py index 6201d424..fb5701c4 100644 --- a/bot/exts/easter/egg_decorating.py +++ b/bot/exts/easter/egg_decorating.py @@ -4,7 +4,7 @@ import random from contextlib import suppress from io import BytesIO from pathlib import Path -from typing import Union +from typing import Optional, Union import discord from PIL import Image @@ -33,7 +33,7 @@ class EggDecorating(commands.Cog): """Decorate some easter eggs!""" @staticmethod - def replace_invalid(colour: str) -> Union[int, None]: + def replace_invalid(colour: str) -> Optional[int]: """Attempts to match with HTML or XKCD colour names, returning the int value.""" with suppress(KeyError): return int(HTML_COLOURS[colour], 16) @@ -44,7 +44,7 @@ class EggDecorating(commands.Cog): @commands.command(aliases=("decorateegg",)) async def eggdecorate( self, ctx: commands.Context, *colours: Union[discord.Colour, str] - ) -> Union[Image.Image, None]: + ) -> Optional[Image.Image]: """ Picks a random egg design and decorates it using the given colours. diff --git a/bot/exts/evergreen/fun.py b/bot/exts/evergreen/fun.py index 1783d7b4..fd17a691 100644 --- a/bot/exts/evergreen/fun.py +++ b/bot/exts/evergreen/fun.py @@ -192,7 +192,7 @@ class Fun(Cog): Returns a tuple of: str: If `text` is a valid discord Message, the contents of the message, else `text`. - Union[Embed, None]: The embed if found in the valid Message, else None + Optional[Embed]: The embed if found in the valid Message, else None """ embed = None diff --git a/bot/exts/halloween/spookynamerate.py b/bot/exts/halloween/spookynamerate.py index 3d6d95fa..bab79e56 100644 --- a/bot/exts/halloween/spookynamerate.py +++ b/bot/exts/halloween/spookynamerate.py @@ -6,7 +6,7 @@ from datetime import datetime, timedelta from logging import getLogger from os import getenv from pathlib import Path -from typing import Union +from typing import Optional from async_rediscache import RedisCache from discord import Embed, Reaction, TextChannel, User @@ -355,7 +355,7 @@ class SpookyNameRate(Cog): return embed - async def get_channel(self) -> Union[TextChannel, None]: + async def get_channel(self) -> Optional[TextChannel]: """Gets the sir-lancebot-channel after waiting until ready.""" await self.bot.wait_until_ready() channel = self.bot.get_channel( 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 From aecc1e6f6f1df012add3ce394496b01e776bbfdf Mon Sep 17 00:00:00 2001 From: Xithrius Date: Wed, 1 Sep 2021 18:44:24 -0700 Subject: Removed None return annotation for any __init__ --- bot/exts/christmas/advent_of_code/_cog.py | 2 +- bot/exts/easter/egghead_quiz.py | 2 +- bot/exts/evergreen/avatar_modification/avatar_modify.py | 2 +- bot/exts/evergreen/battleship.py | 2 +- bot/exts/evergreen/connect_four.py | 4 ++-- bot/exts/evergreen/duck_game.py | 2 +- bot/exts/evergreen/error_handler.py | 2 +- bot/exts/evergreen/fun.py | 2 +- bot/exts/evergreen/minesweeper.py | 2 +- bot/exts/evergreen/recommend_game.py | 2 +- bot/exts/evergreen/trivia_quiz.py | 2 +- bot/exts/evergreen/xkcd.py | 2 +- bot/exts/halloween/spookynamerate.py | 2 +- bot/exts/internal_eval/_helpers.py | 6 +++--- bot/utils/checks.py | 2 +- bot/utils/randomization.py | 2 +- 16 files changed, 19 insertions(+), 19 deletions(-) (limited to 'bot/utils') diff --git a/bot/exts/christmas/advent_of_code/_cog.py b/bot/exts/christmas/advent_of_code/_cog.py index 3d61753b..bc2ccc04 100644 --- a/bot/exts/christmas/advent_of_code/_cog.py +++ b/bot/exts/christmas/advent_of_code/_cog.py @@ -29,7 +29,7 @@ AOC_WHITELIST = AOC_WHITELIST_RESTRICTED + (Channels.advent_of_code,) class AdventOfCode(commands.Cog): """Advent of Code festivities! Ho Ho Ho!""" - def __init__(self, bot: Bot) -> None: + def __init__(self, bot: Bot): self.bot = bot self._base_url = f"https://adventofcode.com/{AocConfig.year}" diff --git a/bot/exts/easter/egghead_quiz.py b/bot/exts/easter/egghead_quiz.py index 7c4960cd..ad550567 100644 --- a/bot/exts/easter/egghead_quiz.py +++ b/bot/exts/easter/egghead_quiz.py @@ -31,7 +31,7 @@ TIMELIMIT = 30 class EggheadQuiz(commands.Cog): """This cog contains the command for the Easter quiz!""" - def __init__(self) -> None: + def __init__(self): self.quiz_messages = {} @commands.command(aliases=("eggheadquiz", "easterquiz")) diff --git a/bot/exts/evergreen/avatar_modification/avatar_modify.py b/bot/exts/evergreen/avatar_modification/avatar_modify.py index 2be09be2..18202902 100644 --- a/bot/exts/evergreen/avatar_modification/avatar_modify.py +++ b/bot/exts/evergreen/avatar_modification/avatar_modify.py @@ -62,7 +62,7 @@ def file_safe_name(effect: str, display_name: str) -> str: class AvatarModify(commands.Cog): """Various commands for users to apply affects to their own avatars.""" - def __init__(self, bot: Bot) -> None: + def __init__(self, bot: Bot): self.bot = bot async def _fetch_user(self, user_id: int) -> Optional[discord.User]: diff --git a/bot/exts/evergreen/battleship.py b/bot/exts/evergreen/battleship.py index 46694f6a..70d22a56 100644 --- a/bot/exts/evergreen/battleship.py +++ b/bot/exts/evergreen/battleship.py @@ -322,7 +322,7 @@ class Game: class Battleship(commands.Cog): """Play the classic game Battleship!""" - def __init__(self, bot: Bot) -> None: + def __init__(self, bot: Bot): self.bot = bot self.games: list[Game] = [] self.waiting: list[discord.Member] = [] diff --git a/bot/exts/evergreen/connect_four.py b/bot/exts/evergreen/connect_four.py index 0f83bf8a..d4d80154 100644 --- a/bot/exts/evergreen/connect_four.py +++ b/bot/exts/evergreen/connect_four.py @@ -181,7 +181,7 @@ class Game: class AI: """The Computer Player for Single-Player games.""" - def __init__(self, bot: Bot, game: Game) -> None: + def __init__(self, bot: Bot, game: Game): self.game = game self.mention = bot.user.mention @@ -256,7 +256,7 @@ class AI: class ConnectFour(commands.Cog): """Connect Four. The Classic Vertical Four-in-a-row Game!""" - def __init__(self, bot: Bot) -> None: + def __init__(self, bot: Bot): self.bot = bot self.games: list[Game] = [] self.waiting: list[discord.Member] = [] diff --git a/bot/exts/evergreen/duck_game.py b/bot/exts/evergreen/duck_game.py index 51e7a98a..614a234b 100644 --- a/bot/exts/evergreen/duck_game.py +++ b/bot/exts/evergreen/duck_game.py @@ -172,7 +172,7 @@ class DuckGame: class DuckGamesDirector(commands.Cog): """A cog for running Duck Duck Duck Goose games.""" - def __init__(self, bot: Bot) -> None: + def __init__(self, bot: Bot): self.bot = bot self.current_games = {} diff --git a/bot/exts/evergreen/error_handler.py b/bot/exts/evergreen/error_handler.py index 3fa8be39..fa9caffb 100644 --- a/bot/exts/evergreen/error_handler.py +++ b/bot/exts/evergreen/error_handler.py @@ -23,7 +23,7 @@ QUESTION_MARK_ICON = "https://cdn.discordapp.com/emojis/512367613339369475.png" class CommandErrorHandler(commands.Cog): """A error handler for the PythonDiscord server.""" - def __init__(self, bot: Bot) -> None: + def __init__(self, bot: Bot): self.bot = bot @staticmethod diff --git a/bot/exts/evergreen/fun.py b/bot/exts/evergreen/fun.py index fd17a691..40743e7b 100644 --- a/bot/exts/evergreen/fun.py +++ b/bot/exts/evergreen/fun.py @@ -54,7 +54,7 @@ def caesar_cipher(text: str, offset: int) -> Iterable[str]: class Fun(Cog): """A collection of general commands for fun.""" - def __init__(self, bot: Bot) -> None: + def __init__(self, bot: Bot): self.bot = bot self._caesar_cipher_embed = json.loads(Path("bot/resources/evergreen/caesar_info.json").read_text("UTF-8")) diff --git a/bot/exts/evergreen/minesweeper.py b/bot/exts/evergreen/minesweeper.py index 75d13d88..a48b5051 100644 --- a/bot/exts/evergreen/minesweeper.py +++ b/bot/exts/evergreen/minesweeper.py @@ -51,7 +51,7 @@ class Game: class Minesweeper(commands.Cog): """Play a game of Minesweeper.""" - def __init__(self) -> None: + def __init__(self): self.games: dict[int, Game] = {} @commands.group(name="minesweeper", aliases=("ms",), invoke_without_command=True) diff --git a/bot/exts/evergreen/recommend_game.py b/bot/exts/evergreen/recommend_game.py index 66597b59..bdd3acb1 100644 --- a/bot/exts/evergreen/recommend_game.py +++ b/bot/exts/evergreen/recommend_game.py @@ -21,7 +21,7 @@ shuffle(game_recs) class RecommendGame(commands.Cog): """Commands related to recommending games.""" - def __init__(self, bot: Bot) -> None: + def __init__(self, bot: Bot): self.bot = bot self.index = 0 diff --git a/bot/exts/evergreen/trivia_quiz.py b/bot/exts/evergreen/trivia_quiz.py index d754cf02..aa4020d6 100644 --- a/bot/exts/evergreen/trivia_quiz.py +++ b/bot/exts/evergreen/trivia_quiz.py @@ -193,7 +193,7 @@ DYNAMIC_QUESTIONS_FORMAT_FUNCS = { class TriviaQuiz(commands.Cog): """A cog for all quiz commands.""" - def __init__(self, bot: Bot) -> None: + def __init__(self, bot: Bot): self.bot = bot self.game_status = {} # A variable to store the game status: either running or not running. diff --git a/bot/exts/evergreen/xkcd.py b/bot/exts/evergreen/xkcd.py index 7c4fc30e..b56c53d9 100644 --- a/bot/exts/evergreen/xkcd.py +++ b/bot/exts/evergreen/xkcd.py @@ -19,7 +19,7 @@ BASE_URL = "https://xkcd.com" class XKCD(Cog): """Retrieving XKCD comics.""" - def __init__(self, bot: Bot) -> None: + def __init__(self, bot: Bot): self.bot = bot self.latest_comic_info: dict[str, Union[str, int]] = {} self.get_latest_comic_info.start() diff --git a/bot/exts/halloween/spookynamerate.py b/bot/exts/halloween/spookynamerate.py index bab79e56..5c21ead7 100644 --- a/bot/exts/halloween/spookynamerate.py +++ b/bot/exts/halloween/spookynamerate.py @@ -91,7 +91,7 @@ class SpookyNameRate(Cog): # will automatically start the scoring and announcing the result (without waiting for 12, so do not expect it to.). # Also, it won't wait for the two hours (when the poll closes). - def __init__(self, bot: Bot) -> None: + def __init__(self, bot: Bot): self.bot = bot self.name = None diff --git a/bot/exts/internal_eval/_helpers.py b/bot/exts/internal_eval/_helpers.py index 6fb07f61..5b2f8f5d 100644 --- a/bot/exts/internal_eval/_helpers.py +++ b/bot/exts/internal_eval/_helpers.py @@ -80,7 +80,7 @@ class EvalContext: clear the context, use the `.internal clear` command. """ - def __init__(self, context_vars: Namespace, local_vars: Namespace) -> None: + def __init__(self, context_vars: Namespace, local_vars: Namespace): self._locals = dict(local_vars) self.context_vars = dict(context_vars) @@ -182,7 +182,7 @@ class EvalContext: class WrapEvalCodeTree(ast.NodeTransformer): """Wraps the AST of eval code with the wrapper function.""" - def __init__(self, eval_code_tree: ast.AST, *args, **kwargs) -> None: + def __init__(self, eval_code_tree: ast.AST, *args, **kwargs): super().__init__(*args, **kwargs) self.eval_code_tree = eval_code_tree @@ -207,7 +207,7 @@ class WrapEvalCodeTree(ast.NodeTransformer): class CaptureLastExpression(ast.NodeTransformer): """Captures the return value from a loose expression.""" - def __init__(self, tree: ast.AST, *args, **kwargs) -> None: + def __init__(self, tree: ast.AST, *args, **kwargs): super().__init__(*args, **kwargs) self.tree = tree self.last_node = list(ast.iter_child_nodes(tree))[-1] diff --git a/bot/utils/checks.py b/bot/utils/checks.py index d5c06728..612d1ed6 100644 --- a/bot/utils/checks.py +++ b/bot/utils/checks.py @@ -22,7 +22,7 @@ log = logging.getLogger(__name__) class InWhitelistCheckFailure(CheckFailure): """Raised when the `in_whitelist` check fails.""" - def __init__(self, redirect_channel: Optional[int]) -> None: + def __init__(self, redirect_channel: Optional[int]): self.redirect_channel = redirect_channel if redirect_channel: diff --git a/bot/utils/randomization.py b/bot/utils/randomization.py index 3360ef44..c9eabbd2 100644 --- a/bot/utils/randomization.py +++ b/bot/utils/randomization.py @@ -11,7 +11,7 @@ class RandomCycle: The iterable is reshuffled after each full cycle. """ - def __init__(self, iterable: Iterable) -> None: + def __init__(self, iterable: Iterable): self.iterable = list(iterable) self.index = itertools.cycle(range(len(iterable))) -- cgit v1.2.3