From 760102edf772b9a0eee90eadc2bf2225b50eb963 Mon Sep 17 00:00:00 2001 From: Isaac Beh Date: Thu, 7 Mar 2024 22:33:48 +1000 Subject: [PATCH] Fixed various typing issues --- pyproject.toml | 3 --- uqcsbot/error_handler.py | 4 +++- uqcsbot/uptime.py | 2 +- uqcsbot/working_on.py | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b6c2175a..f9548578 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,15 +43,12 @@ build-backend = "poetry.core.masonry.api" strict = ["**"] exclude = [ "**/bot.py", - "**/error_handler.py", "**/events.py", "**/gaming.py", "**/member_counter.py", "**/remindme.py", "**/snailrace.py", "**/starboard.py", - "**/uptime.py", - "**/working_on.py", "**/utils/snailrace_utils.py", ] diff --git a/uqcsbot/error_handler.py b/uqcsbot/error_handler.py index 98a55bc2..e6a1ec07 100644 --- a/uqcsbot/error_handler.py +++ b/uqcsbot/error_handler.py @@ -1,6 +1,8 @@ from discord.ext import commands from discord.ext.commands.errors import MissingRequiredArgument import logging +from typing import Any +from uqcsbot.bot import UQCSBot """ TODO: this is bundled with advent.py and should be removed. @@ -9,7 +11,7 @@ class ErrorHandler(commands.Cog): @commands.Cog.listener() - async def on_command_error(self, ctx: commands.Context, err): + async def on_command_error(self, ctx: commands.Context[UQCSBot], err: Any): if isinstance(err, MissingRequiredArgument): await ctx.send( "Missing required argument. For further information refer to `!help`" diff --git a/uqcsbot/uptime.py b/uqcsbot/uptime.py index ad38d7c5..f1caaa2a 100644 --- a/uqcsbot/uptime.py +++ b/uqcsbot/uptime.py @@ -22,7 +22,7 @@ async def on_ready(self): self.bot.uqcs_server.channels, name=self.CHANNEL_NAME ) - if channel is not None: + if isinstance(channel, discord.TextChannel): if random.randint(1, 100) == 1: await channel.send("Oopsie, I webooted uwu >_<") else: diff --git a/uqcsbot/working_on.py b/uqcsbot/working_on.py index e3af632c..8ebfea12 100644 --- a/uqcsbot/working_on.py +++ b/uqcsbot/working_on.py @@ -19,7 +19,7 @@ def __init__(self, bot: UQCSBot): async def workingon(self): """5pm ping for 2 lucky server members to share what they have been working on.""" members = list(self.bot.get_all_members()) - message = [] + message: list[str] = [] while len(message) < 2: chosen = choice(members) @@ -33,7 +33,7 @@ async def workingon(self): self.bot.uqcs_server.channels, name=GENERAL_CHANNEL ) - if general_channel is not None: + if isinstance(general_channel, discord.TextChannel): await general_channel.send( "\n".join(message), allowed_mentions=discord.AllowedMentions(