From 68ce9cda40167cd7c656dabe96d0130eee2018ce Mon Sep 17 00:00:00 2001 From: ajax146 <31014239+ajax146@users.noreply.github.com> Date: Thu, 25 Jul 2024 18:31:27 -0400 Subject: [PATCH] Formatting --- techsupport_bot/botlogging/common.py | 10 ++++----- techsupport_bot/botlogging/embed.py | 20 +++++++++--------- techsupport_bot/commands/__init__.py | 1 + techsupport_bot/commands/animal.py | 8 +++---- techsupport_bot/commands/application.py | 2 +- techsupport_bot/commands/burn.py | 2 +- techsupport_bot/commands/chatgpt.py | 4 ++-- techsupport_bot/commands/conch.py | 4 ++-- techsupport_bot/commands/duck.py | 14 ++++++++----- techsupport_bot/commands/emoji.py | 2 +- techsupport_bot/commands/extension.py | 2 +- techsupport_bot/commands/factoids.py | 12 +++++------ techsupport_bot/commands/giphy.py | 4 ++-- techsupport_bot/commands/github.py | 2 +- techsupport_bot/commands/google.py | 8 ++++--- techsupport_bot/commands/grab.py | 2 +- techsupport_bot/commands/hangman.py | 4 ++-- techsupport_bot/commands/hug.py | 4 ++-- techsupport_bot/commands/ipinfo.py | 4 ++-- techsupport_bot/commands/iss.py | 4 ++-- techsupport_bot/commands/joke.py | 2 +- techsupport_bot/commands/kanye.py | 4 ++-- techsupport_bot/commands/lenny.py | 2 +- techsupport_bot/commands/news.py | 14 ++++++------- techsupport_bot/commands/poll.py | 6 +++--- techsupport_bot/commands/protect.py | 6 +++--- techsupport_bot/commands/relay.py | 2 +- techsupport_bot/commands/role.py | 2 +- techsupport_bot/commands/roll.py | 4 +++- techsupport_bot/commands/rules.py | 2 +- techsupport_bot/commands/translate.py | 2 +- techsupport_bot/commands/urban.py | 6 +++--- techsupport_bot/commands/wolfram.py | 6 ++++-- techsupport_bot/commands/xkcd.py | 4 ++-- techsupport_bot/core/cogs.py | 6 +++--- techsupport_bot/core/custom_errors.py | 2 +- techsupport_bot/core/databases.py | 21 +++++++------------ techsupport_bot/ircrelay/irc.py | 15 ++++++------- .../commands_tests/test_extensions_wyr.py | 2 +- techsupport_bot/ui/application.py | 4 ++-- techsupport_bot/ui/appnotice.py | 4 +++- 41 files changed, 118 insertions(+), 111 deletions(-) diff --git a/techsupport_bot/botlogging/common.py b/techsupport_bot/botlogging/common.py index 815145f2..bc231716 100644 --- a/techsupport_bot/botlogging/common.py +++ b/techsupport_bot/botlogging/common.py @@ -19,10 +19,10 @@ class LogLevel(Enum): ERROR (str): Representation of error """ - DEBUG = "debug" - INFO = "info" - WARNING = "warning" - ERROR = "error" + DEBUG: str = "debug" + INFO: str = "info" + WARNING: str = "warning" + ERROR: str = "error" @dataclass @@ -32,7 +32,7 @@ class LogContext: Attributes: guild (discord.Guild | None): The guild the log occured with. Optional - channel (discord.abc.Messageble | None): The channel, DM, thread, + channel (discord.abc.Messageable | None): The channel, DM, thread, or other messagable the log occured in """ diff --git a/techsupport_bot/botlogging/embed.py b/techsupport_bot/botlogging/embed.py index 8ebe6e03..c941eb93 100644 --- a/techsupport_bot/botlogging/embed.py +++ b/techsupport_bot/botlogging/embed.py @@ -20,8 +20,8 @@ class LogEmbed(discord.Embed): color (discord.Color): The color of the embed """ - title = None - color = None + title: str = None + color: discord.Color = None def __init__(self: Self, message: str) -> None: super().__init__( @@ -54,8 +54,8 @@ class InfoEmbed(LogEmbed): color (discord.Color): The color of the embed """ - title = "info" - color = discord.Color.green() + title: str = "info" + color: discord.Color = discord.Color.green() class DebugEmbed(LogEmbed): @@ -66,8 +66,8 @@ class DebugEmbed(LogEmbed): color (discord.Color): The color of the embed """ - title = "debug" - color = discord.Color.dark_green() + title: str = "debug" + color: discord.Color = discord.Color.dark_green() class WarningEmbed(LogEmbed): @@ -78,8 +78,8 @@ class WarningEmbed(LogEmbed): color (discord.Color): The color of the embed """ - title = "warning" - color = discord.Color.gold() + title: str = "warning" + color: discord.Color = discord.Color.gold() class ErrorEmbed(LogEmbed): @@ -90,5 +90,5 @@ class ErrorEmbed(LogEmbed): color (discord.Color): The color of the embed """ - title = "error" - color = discord.Color.red() + title: str = "error" + color: discord.Color = discord.Color.red() diff --git a/techsupport_bot/commands/__init__.py b/techsupport_bot/commands/__init__.py index ab0153aa..ac6cbd26 100644 --- a/techsupport_bot/commands/__init__.py +++ b/techsupport_bot/commands/__init__.py @@ -16,5 +16,6 @@ from .linter import * from .listen import * from .mock import * +from .relay import * from .roll import * from .wyr import * diff --git a/techsupport_bot/commands/animal.py b/techsupport_bot/commands/animal.py index e2f8794d..9062b583 100644 --- a/techsupport_bot/commands/animal.py +++ b/techsupport_bot/commands/animal.py @@ -31,10 +31,10 @@ class Animals(cogs.BaseCog): FROG_API_URL (str): The URL for the frog API """ - CAT_API_URL = "https://api.thecatapi.com/v1/images/search?limit=1&api_key={}" - DOG_API_URL = "https://dog.ceo/api/breeds/image/random" - FOX_API_URL = "https://randomfox.ca/floof/" - FROG_API_URL = "https://frogs.media/api/random" + CAT_API_URL: str = "https://api.thecatapi.com/v1/images/search?limit=1&api_key={}" + DOG_API_URL: str = "https://dog.ceo/api/breeds/image/random" + FOX_API_URL: str = "https://randomfox.ca/floof/" + FROG_API_URL: str = "https://frogs.media/api/random" @auxiliary.with_typing @commands.command(name="cat", brief="Gets a cat", description="Gets a cat") diff --git a/techsupport_bot/commands/application.py b/techsupport_bot/commands/application.py index 6dcb2578..8005029b 100644 --- a/techsupport_bot/commands/application.py +++ b/techsupport_bot/commands/application.py @@ -202,7 +202,7 @@ class ApplicationManager(cogs.LoopCog): application_group (app_commands.Group): The group for the /application commands """ - application_group = app_commands.Group( + application_group: app_commands.Group = app_commands.Group( name="application", description="...", extras={"module": "application"} ) diff --git a/techsupport_bot/commands/burn.py b/techsupport_bot/commands/burn.py index fb8fbf89..8d0c3b46 100644 --- a/techsupport_bot/commands/burn.py +++ b/techsupport_bot/commands/burn.py @@ -33,7 +33,7 @@ class Burn(cogs.BaseCog): PHRASES (list[str]): The list of phrases to pick from """ - PHRASES = [ + PHRASES: list[str] = [ "Sick BURN!", "Someone is going to need ointment for that BURN!", "Fire! Call 911! Someone just got BURNED!", diff --git a/techsupport_bot/commands/chatgpt.py b/techsupport_bot/commands/chatgpt.py index cc1ff0bf..8628af51 100644 --- a/techsupport_bot/commands/chatgpt.py +++ b/techsupport_bot/commands/chatgpt.py @@ -53,7 +53,7 @@ class ChatGPT(cogs.BaseCog): SYSTEM_PROMPT (dict[str, str]): The default starting prompt for chatGPT """ - API_URL = "https://api.openai.com/v1/chat/completions" + API_URL: str = "https://api.openai.com/v1/chat/completions" async def preconfig(self: Self) -> None: """Sets up the dict""" @@ -62,7 +62,7 @@ async def preconfig(self: Self) -> None: max_age_seconds=3600, ) - SYSTEM_PROMPT = [ + SYSTEM_PROMPT: dict[str, str] = [ { "role": "system", "content": ( diff --git a/techsupport_bot/commands/conch.py b/techsupport_bot/commands/conch.py index fa731e08..a574e53b 100644 --- a/techsupport_bot/commands/conch.py +++ b/techsupport_bot/commands/conch.py @@ -35,7 +35,7 @@ class MagicConch(cogs.BaseCog): """ - RESPONSES = [ + RESPONSES: list[str] = [ "As I see it, yes.", "Ask again later.", "Better not tell you now.", @@ -57,7 +57,7 @@ class MagicConch(cogs.BaseCog): "Yes - definitely.", "You may rely on it.", ] - PIC_URL = "https://i.imgur.com/vdvGrsR.png" + PIC_URL: str = "https://i.imgur.com/vdvGrsR.png" def format_question(self: Self, question: str) -> str: """This formats a question properly. It will crop it if needed, and add a "?" to the end diff --git a/techsupport_bot/commands/duck.py b/techsupport_bot/commands/duck.py index 32fcb804..1f7cdfe2 100644 --- a/techsupport_bot/commands/duck.py +++ b/techsupport_bot/commands/duck.py @@ -101,14 +101,18 @@ class DuckHunt(cogs.LoopCog): CHANNELS_KEY (str): The config item for the channels that the duck hunt should run """ - DUCK_PIC_URL = "https://cdn.icon-icons.com/icons2/1446/PNG/512/22276duck_98782.png" - BEFRIEND_URL = ( + DUCK_PIC_URL: str = ( + "https://cdn.icon-icons.com/icons2/1446/PNG/512/22276duck_98782.png" + ) + BEFRIEND_URL: str = ( "https://cdn.icon-icons.com/icons2/603/PNG/512/" + "heart_love_valentines_relationship_dating_date_icon-icons.com_55985.png" ) - KILL_URL = "https://cdn.icon-icons.com/icons2/1919/PNG/512/huntingtarget_122049.png" - ON_START = False - CHANNELS_KEY = "hunt_channels" + KILL_URL: str = ( + "https://cdn.icon-icons.com/icons2/1919/PNG/512/huntingtarget_122049.png" + ) + ON_START: bool = False + CHANNELS_KEY: str = "hunt_channels" async def loop_preconfig(self: Self) -> None: """Preconfig for cooldowns""" diff --git a/techsupport_bot/commands/emoji.py b/techsupport_bot/commands/emoji.py index 91afe9a5..56d496d7 100644 --- a/techsupport_bot/commands/emoji.py +++ b/techsupport_bot/commands/emoji.py @@ -35,7 +35,7 @@ class Emojis(cogs.BaseCog): KEY_MAP (dict[str,str]): Some manual mappings from character to emoji """ - KEY_MAP = {"?": "question", "!": "exclamation"} + KEY_MAP: dict[str, str] = {"?": "question", "!": "exclamation"} @classmethod def emoji_from_char(cls: Self, char: str) -> str: diff --git a/techsupport_bot/commands/extension.py b/techsupport_bot/commands/extension.py index 192f7f03..7891a58d 100644 --- a/techsupport_bot/commands/extension.py +++ b/techsupport_bot/commands/extension.py @@ -41,7 +41,7 @@ class ExtensionControl(cogs.BaseCog): extension_app_command_group (app_commands.Group): The group for the /extension commands """ - extension_app_command_group = app_commands.Group( + extension_app_command_group: app_commands.Group = app_commands.Group( name="extension", description="...", extras={"module": "extension"} ) diff --git a/techsupport_bot/commands/factoids.py b/techsupport_bot/commands/factoids.py index 1f5228df..d8261863 100644 --- a/techsupport_bot/commands/factoids.py +++ b/techsupport_bot/commands/factoids.py @@ -188,10 +188,10 @@ class Properties(Enum): PROTECTED (str): Representation of protected """ - HIDDEN = "hidden" - DISABLED = "disabled" - RESTRICTED = "restricted" - PROTECTED = "protected" + HIDDEN: str = "hidden" + DISABLED: str = "disabled" + RESTRICTED: str = "restricted" + PROTECTED: str = "protected" class FactoidManager(cogs.MatchCog): @@ -203,13 +203,13 @@ class FactoidManager(cogs.MatchCog): factoid_app_group (app_commands.Group): Group for /factoid commands """ - CRON_REGEX = ( + CRON_REGEX: str = ( r"^((\*|([0-5]?\d|\*\/\d+)(-([0-5]?\d))?)(,\s*(\*|([0-5]?\d|\*\/\d+)(-([0-5]" + r"?\d))?)){0,59}\s+){4}(\*|([0-7]?\d|\*(\/[1-9]|[1-5]\d)|mon|tue|wed|thu|fri|sat|sun" + r")|\*\/[1-9])$" ) - factoid_app_group = app_commands.Group( + factoid_app_group: app_commands.Group = app_commands.Group( name="factoid", description="Command Group for the Factoids Extension" ) diff --git a/techsupport_bot/commands/giphy.py b/techsupport_bot/commands/giphy.py index a7df7f3c..9f2b276a 100644 --- a/techsupport_bot/commands/giphy.py +++ b/techsupport_bot/commands/giphy.py @@ -40,8 +40,8 @@ class Giphy(cogs.BaseCog): SEARCH_LIMIT (int): The max amount of gifs to search for """ - GIPHY_URL = "http://api.giphy.com/v1/gifs/search?q={}&api_key={}&limit={}" - SEARCH_LIMIT = 10 + GIPHY_URL: str = "http://api.giphy.com/v1/gifs/search?q={}&api_key={}&limit={}" + SEARCH_LIMIT: int = 10 @staticmethod def parse_url(url: str) -> str: diff --git a/techsupport_bot/commands/github.py b/techsupport_bot/commands/github.py index 739a4055..e0e34f55 100644 --- a/techsupport_bot/commands/github.py +++ b/techsupport_bot/commands/github.py @@ -55,7 +55,7 @@ class IssueCreator(cogs.BaseCog): """ - GITHUB_API_BASE_URL = "https://api.github.com" + GITHUB_API_BASE_URL: str = "https://api.github.com" @commands.check(auxiliary.bot_admin_check_context) @auxiliary.with_typing diff --git a/techsupport_bot/commands/google.py b/techsupport_bot/commands/google.py index 9bfb4c52..75db5fac 100644 --- a/techsupport_bot/commands/google.py +++ b/techsupport_bot/commands/google.py @@ -53,9 +53,11 @@ class Googler(cogs.BaseCog): ICON_URL (str): The google icon """ - GOOGLE_URL = "https://www.googleapis.com/customsearch/v1" - YOUTUBE_URL = "https://www.googleapis.com/youtube/v3/search?part=id&maxResults=10" - ICON_URL = ( + GOOGLE_URL: str = "https://www.googleapis.com/customsearch/v1" + YOUTUBE_URL: str = ( + "https://www.googleapis.com/youtube/v3/search?part=id&maxResults=10" + ) + ICON_URL: str = ( "https://cdn.icon-icons.com/icons2/673/PNG/512/Google_icon-icons.com_60497.png" ) diff --git a/techsupport_bot/commands/grab.py b/techsupport_bot/commands/grab.py index 27099dad..1d278a85 100644 --- a/techsupport_bot/commands/grab.py +++ b/techsupport_bot/commands/grab.py @@ -75,7 +75,7 @@ class Grabber(cogs.BaseCog): SEARCH_LIMIT (int): The max amount of messages to search when grabbing """ - SEARCH_LIMIT = 20 + SEARCH_LIMIT: int = 20 @auxiliary.with_typing @commands.guild_only() diff --git a/techsupport_bot/commands/hangman.py b/techsupport_bot/commands/hangman.py index 07daa687..12300e9c 100644 --- a/techsupport_bot/commands/hangman.py +++ b/techsupport_bot/commands/hangman.py @@ -50,7 +50,7 @@ class HangmanGame: ValueError: A valid alphabetic word wasn't provided """ - HANG_PICS = [ + HANG_PICS: list[str] = [ """ +---+ | | @@ -108,7 +108,7 @@ class HangmanGame: | =========""", ] - FINAL_STEP = len(HANG_PICS) - 1 + FINAL_STEP: int = len(HANG_PICS) - 1 def __init__(self: Self, word: str) -> None: if not word or "_" in word or not word.isalpha(): diff --git a/techsupport_bot/commands/hug.py b/techsupport_bot/commands/hug.py index eae1ffe3..29b157cb 100644 --- a/techsupport_bot/commands/hug.py +++ b/techsupport_bot/commands/hug.py @@ -31,7 +31,7 @@ class Hugger(cogs.BaseCog): """ - HUGS_SELECTION = [ + HUGS_SELECTION: list[str] = [ "{user_giving_hug} hugs {user_to_hug} forever and ever and ever", "{user_giving_hug} wraps arms around {user_to_hug} and clings forever", "{user_giving_hug} hugs {user_to_hug} and gives their hair a sniff", @@ -45,7 +45,7 @@ class Hugger(cogs.BaseCog): "{user_giving_hug} smothers {user_to_hug} with a loving hug", "{user_giving_hug} squeezes {user_to_hug} to death", ] - ICON_URL = ( + ICON_URL: str = ( "https://cdn.icon-icons.com/icons2/1648/PNG/512/10022huggingface_110042.png" ) diff --git a/techsupport_bot/commands/ipinfo.py b/techsupport_bot/commands/ipinfo.py index 5d777e1e..2f147aa8 100644 --- a/techsupport_bot/commands/ipinfo.py +++ b/techsupport_bot/commands/ipinfo.py @@ -29,8 +29,8 @@ class IPInfo(cogs.BaseCog): IP_ICON_URL (str): The URL for the IP info icon """ - API_URL = "https://ipinfo.io" - IP_ICON_URL = ( + API_URL: str = "https://ipinfo.io" + IP_ICON_URL: str = ( "https://cdn.icon-icons.com/icons2/1858/PNG/512/" "iconfinder-dedicatedipaddress-4263513_117864.png" ) diff --git a/techsupport_bot/commands/iss.py b/techsupport_bot/commands/iss.py index a3a89b88..e79f1ef3 100644 --- a/techsupport_bot/commands/iss.py +++ b/techsupport_bot/commands/iss.py @@ -30,8 +30,8 @@ class ISSLocator(cogs.BaseCog): """ - ISS_URL = "http://api.open-notify.org/iss-now.json" - GEO_URL = "https://geocode.xyz/{},{}?geoit=json" + ISS_URL: str = "http://api.open-notify.org/iss-now.json" + GEO_URL: str = "https://geocode.xyz/{},{}?geoit=json" @auxiliary.with_typing @commands.command( diff --git a/techsupport_bot/commands/joke.py b/techsupport_bot/commands/joke.py index 282fd557..4e8f0d5c 100644 --- a/techsupport_bot/commands/joke.py +++ b/techsupport_bot/commands/joke.py @@ -42,7 +42,7 @@ class Joker(cogs.BaseCog): """ - API_URL = "https://v2.jokeapi.dev/joke/Any" + API_URL: str = "https://v2.jokeapi.dev/joke/Any" async def call_api( self: Self, ctx: commands.Context, config: munch.Munch diff --git a/techsupport_bot/commands/kanye.py b/techsupport_bot/commands/kanye.py index ff491224..66e21e34 100644 --- a/techsupport_bot/commands/kanye.py +++ b/techsupport_bot/commands/kanye.py @@ -56,8 +56,8 @@ class KanyeQuotes(cogs.LoopCog): KANYE_PICS (list[str]): The list of Kanye pics to pick from randomly """ - API_URL = "https://api.kanye.rest" - KANYE_PICS = [ + API_URL: str = "https://api.kanye.rest" + KANYE_PICS: list[str] = [ "https://i.imgur.com/ITmTXGz.jpg", "https://i.imgur.com/o8BkPrL.jpg", "https://i.imgur.com/sA5qP3F.jpg", diff --git a/techsupport_bot/commands/lenny.py b/techsupport_bot/commands/lenny.py index cfbb990c..672449a4 100644 --- a/techsupport_bot/commands/lenny.py +++ b/techsupport_bot/commands/lenny.py @@ -30,7 +30,7 @@ class Lenny(cogs.BaseCog): """ - LENNYS_SELECTION = [ + LENNYS_SELECTION: list[str] = [ "( ͡° ͜ʖ ͡°)", "( ͠° ͟ʖ ͡°)", "( ͡ʘ ͜ʖ ͡ʘ)", diff --git a/techsupport_bot/commands/news.py b/techsupport_bot/commands/news.py index 277efe25..5f55aba5 100644 --- a/techsupport_bot/commands/news.py +++ b/techsupport_bot/commands/news.py @@ -82,13 +82,13 @@ class Category(enum.Enum): """ - BUSINESS = "business" - ENTERTAINMENT = "entertainment" - GENERAL = "general" - HEALTH = "health" - SCIENCE = "science" - SPORTS = "sports" - TECH = "technology" + BUSINESS: str = "business" + ENTERTAINMENT: str = "entertainment" + GENERAL: str = "general" + HEALTH: str = "health" + SCIENCE: str = "science" + SPORTS: str = "sports" + TECH: str = "technology" class News(cogs.LoopCog): diff --git a/techsupport_bot/commands/poll.py b/techsupport_bot/commands/poll.py index f2b5ba08..cff9c2ad 100644 --- a/techsupport_bot/commands/poll.py +++ b/techsupport_bot/commands/poll.py @@ -110,9 +110,9 @@ class ReactionPoller(PollGenerator): """ - OPTION_EMOJIS = ["one", "two", "three", "four", "five"] - STOP_EMOJI = "\u26d4" - EXAMPLE_DATA = { + OPTION_EMOJIS: list[str] = ["one", "two", "three", "four", "five"] + STOP_EMOJI: str = "\u26d4" + EXAMPLE_DATA: dict[str, str | list[str] | int] = { "question": "Best ice cream?", "options": ["Chocolate", "Vanilla", "Strawberry", "Cookie Dough", "Other..."], "timeout": 60, diff --git a/techsupport_bot/commands/protect.py b/techsupport_bot/commands/protect.py index 38e6ba17..0a9515ec 100644 --- a/techsupport_bot/commands/protect.py +++ b/techsupport_bot/commands/protect.py @@ -154,14 +154,14 @@ class Protector(cogs.MatchCog): """ - ALERT_ICON_URL = ( + ALERT_ICON_URL: str = ( "https://cdn.icon-icons.com/icons2/2063/PNG/512/" + "alert_danger_warning_notification_icon_124692.png" ) - CLIPBOARD_ICON_URL = ( + CLIPBOARD_ICON_URL: str = ( "https://icon-icons.com/icons2/203/PNG/128/diagram-30_24487.png" ) - CHARS_PER_NEWLINE = 80 + CHARS_PER_NEWLINE: int = 80 async def preconfig(self: Self) -> None: """Method to preconfig the protect.""" diff --git a/techsupport_bot/commands/relay.py b/techsupport_bot/commands/relay.py index 9340183e..dc79bcc5 100644 --- a/techsupport_bot/commands/relay.py +++ b/techsupport_bot/commands/relay.py @@ -47,7 +47,7 @@ class DiscordToIRC(cogs.MatchCog): """ - mapping = None # bidict - discord:irc + mapping: bidict = None # bidict - discord:irc async def preconfig(self: Self) -> None: """The preconfig setup for the discord side diff --git a/techsupport_bot/commands/role.py b/techsupport_bot/commands/role.py index 8c1f5010..3a7c7300 100644 --- a/techsupport_bot/commands/role.py +++ b/techsupport_bot/commands/role.py @@ -72,7 +72,7 @@ def __init__(self: Self, bot: bot.TechSupportBot) -> None: ) self.bot.tree.add_command(self.ctx_menu) - role_group = app_commands.Group(name="role", description="...") + role_group: app_commands.Group = app_commands.Group(name="role", description="...") async def preconfig(self: Self) -> None: """This setups the global lock on the role command, to avoid conflicts""" diff --git a/techsupport_bot/commands/roll.py b/techsupport_bot/commands/roll.py index a729b1a8..bdab039e 100644 --- a/techsupport_bot/commands/roll.py +++ b/techsupport_bot/commands/roll.py @@ -30,7 +30,9 @@ class Roller(cogs.BaseCog): """ - ICON_URL = "https://cdn.icon-icons.com/icons2/1465/PNG/512/678gamedice_100992.png" + ICON_URL: str = ( + "https://cdn.icon-icons.com/icons2/1465/PNG/512/678gamedice_100992.png" + ) @auxiliary.with_typing @commands.command( diff --git a/techsupport_bot/commands/rules.py b/techsupport_bot/commands/rules.py index a33ea914..6fff45a2 100644 --- a/techsupport_bot/commands/rules.py +++ b/techsupport_bot/commands/rules.py @@ -33,7 +33,7 @@ class Rules(cogs.BaseCog): """ - RULE_ICON_URL = ( + RULE_ICON_URL: str = ( "https://cdn.icon-icons.com/icons2/907/PNG" "/512/balance-scale-of-justice_icon-icons.com_70554.png" ) diff --git a/techsupport_bot/commands/translate.py b/techsupport_bot/commands/translate.py index 5151d0de..36e72eb8 100644 --- a/techsupport_bot/commands/translate.py +++ b/techsupport_bot/commands/translate.py @@ -28,7 +28,7 @@ class Translator(cogs.BaseCog): """ - API_URL = "https://api.mymemory.translated.net/get?q={}&langpair={}|{}" + API_URL: str = "https://api.mymemory.translated.net/get?q={}&langpair={}|{}" @auxiliary.with_typing @commands.command( diff --git a/techsupport_bot/commands/urban.py b/techsupport_bot/commands/urban.py index a34eaf78..6f54edd4 100644 --- a/techsupport_bot/commands/urban.py +++ b/techsupport_bot/commands/urban.py @@ -42,9 +42,9 @@ class UrbanDictionary(cogs.BaseCog): """ - BASE_URL = "http://api.urbandictionary.com/v0/define?term=" - SEE_MORE_URL = "https://www.urbandictionary.com/define.php?term=" - ICON_URL = "https://cdn.icon-icons.com/icons2/114/PNG/512/dictionary_19159.png" + BASE_URL: str = "http://api.urbandictionary.com/v0/define?term=" + SEE_MORE_URL: str = "https://www.urbandictionary.com/define.php?term=" + ICON_URL: str = "https://cdn.icon-icons.com/icons2/114/PNG/512/dictionary_19159.png" @auxiliary.with_typing @commands.command( diff --git a/techsupport_bot/commands/wolfram.py b/techsupport_bot/commands/wolfram.py index 9a89fa02..08c9dddc 100644 --- a/techsupport_bot/commands/wolfram.py +++ b/techsupport_bot/commands/wolfram.py @@ -41,8 +41,10 @@ class Wolfram(cogs.BaseCog): """ - API_URL = "http://api.wolframalpha.com/v1/result?appid={}&i={}" - ICON_URL = "https://cdn.icon-icons.com/icons2/2107/PNG/512/file_type_wolfram_icon_130071.png" + API_URL: str = "http://api.wolframalpha.com/v1/result?appid={}&i={}" + ICON_URL: str = ( + "https://cdn.icon-icons.com/icons2/2107/PNG/512/file_type_wolfram_icon_130071.png" + ) @auxiliary.with_typing @commands.command( diff --git a/techsupport_bot/commands/xkcd.py b/techsupport_bot/commands/xkcd.py index 4b10afda..987d3ffa 100644 --- a/techsupport_bot/commands/xkcd.py +++ b/techsupport_bot/commands/xkcd.py @@ -32,8 +32,8 @@ class XKCD(cogs.BaseCog): """ - MOST_RECENT_API_URL = "https://xkcd.com/info.0.json" - SPECIFIC_API_URL = "https://xkcd.com/%s/info.0.json" + MOST_RECENT_API_URL: str = "https://xkcd.com/info.0.json" + SPECIFIC_API_URL: str = "https://xkcd.com/%s/info.0.json" @commands.group( brief="xkcd extension parent", diff --git a/techsupport_bot/core/cogs.py b/techsupport_bot/core/cogs.py index ce05c080..004ae8cc 100644 --- a/techsupport_bot/core/cogs.py +++ b/techsupport_bot/core/cogs.py @@ -29,8 +29,8 @@ class BaseCog(commands.Cog): if it needs to be different than the file name """ - COG_TYPE = "Base" - KEEP_COG_ON_FAILURE = False + COG_TYPE: str = "Base" + KEEP_COG_ON_FAILURE: bool = False def __init__( self: Self, @@ -101,7 +101,7 @@ class MatchCog(BaseCog): COG_TYPE (str): The string representation for the type of cog """ - COG_TYPE = "Match" + COG_TYPE: str = "Match" @commands.Cog.listener() async def on_message(self: Self, message: discord.Message) -> None: diff --git a/techsupport_bot/core/custom_errors.py b/techsupport_bot/core/custom_errors.py index bc23cb1a..f90f7f00 100644 --- a/techsupport_bot/core/custom_errors.py +++ b/techsupport_bot/core/custom_errors.py @@ -79,7 +79,7 @@ class ErrorResponse: dont_print_trace (bool): If true, the stack trace generated will not be logged """ - DEFAULT_MESSAGE = "I ran into an error processing your command" + DEFAULT_MESSAGE: str = "I ran into an error processing your command" def __init__( self: Self, diff --git a/techsupport_bot/core/databases.py b/techsupport_bot/core/databases.py index 32e82994..c30239fb 100644 --- a/techsupport_bot/core/databases.py +++ b/techsupport_bot/core/databases.py @@ -24,7 +24,6 @@ class Applications(bot.db.Model): Currenty used in application.py Attributes: - __tablename__ (str): The name of the table in postgres pk (int): The automatic primary key guild_id (str): The string of the guild ID the application is in applicant_name (str): The name of the user who submitted the app @@ -53,7 +52,6 @@ class ApplicationBans(bot.db.Model): Currently used in application.py and who.py Attributes: - __tablename__ (str): The name of the table in postgres pk (int): The automatic primary key guild_id (str): The string of the guild ID the applicant is banned in applicant_id (str): The string representation of the ID of the user @@ -70,7 +68,6 @@ class DuckUser(bot.db.Model): Currently used in duck.py Attributes: - __tablename__ (str): The name of the table in postgres pk (int): The automatic primary key author_id (str): The string representation of the ID of the user guild_id (str): The string of the guild ID the duckuser has participated in @@ -95,7 +92,6 @@ class Factoid(bot.db.Model): Currently used in factoid.py Attributes: - __tablename__ (str): The name of the table in postgres factoid_id (int): The primary key of the factoid name (str): The name of the factoid guild (str): The string guild ID for the guild that the factoid is in @@ -128,7 +124,6 @@ class FactoidJob(bot.db.Model): Currently used in factoid.py Attributes: - __tablename__ (str): The name of the table in postgres job_id (int): The primary key, ID of the job factoid (int): The primary key of the linked factoid channel (str): The channel this loop needs to run in @@ -149,7 +144,6 @@ class Grab(bot.db.Model): Currently used in grab.py Attributes: - __tablename__ (str): The name of the table in postgres pk (int): The primary key for this database author_id (str): The ID of the author of the original grab message channel (str): The channel the message was grabbed from @@ -174,7 +168,6 @@ class IRCChannelMapping(bot.db.Model): Currently used in relay.py Attributes: - __tablename__ (str): The name of the table in postgres map_id (int): The primary key for the database guild_id (str): The guild where the discord channel exists at discord_channel_id (str): The ID of the discord channel @@ -182,6 +175,7 @@ class IRCChannelMapping(bot.db.Model): """ __tablename__ = "ircchannelmap" + map_id = bot.db.Column(bot.db.Integer, primary_key=True) guild_id = bot.db.Column(bot.db.String, default=None) discord_channel_id = bot.db.Column(bot.db.String, default=None) @@ -192,11 +186,11 @@ class ModmailBan(bot.db.Model): Currently used in modmail.py Attributes: - __tablename__ (str): The name of the table in postgres user_id (str): The ID of the user banned from modmail """ __tablename__ = "modmail_bans" + user_id = bot.db.Column(bot.db.String, default=None, primary_key=True) class UserNote(bot.db.Model): @@ -204,7 +198,6 @@ class UserNote(bot.db.Model): Currently used in who.py Attributes: - __tablename__ (str): The name of the table in postgres pk (int): The primary key for this database user_id (str): The user ID that has a note guild_id (str): The guild ID that the note belongs to @@ -227,7 +220,6 @@ class Warning(bot.db.Model): Currently used in protect.py and who.py Attributes: - __tablename__ (str): The name of the table in postgres pk (int): The primary key for the database user_id (str): The user who got warned guild_id (str): The guild this warn occured in @@ -236,6 +228,7 @@ class Warning(bot.db.Model): """ __tablename__ = "warnings" + pk = bot.db.Column(bot.db.Integer, primary_key=True) user_id = bot.db.Column(bot.db.String) guild_id = bot.db.Column(bot.db.String) @@ -247,7 +240,6 @@ class Config(bot.db.Model): Currently used nearly everywhere Attributes: - __tablename__ (str): The name of the table in postgres pk (int): The primary key for the database guild_id (str): The ID of the guild this config is for config (str): The config text @@ -255,6 +247,7 @@ class Config(bot.db.Model): """ __tablename__ = "guild_config" + pk = bot.db.Column(bot.db.Integer, primary_key=True) guild_id = bot.db.Column(bot.db.String) config = bot.db.Column(bot.db.String) @@ -265,13 +258,13 @@ class Listener(bot.db.Model): Currently used in listen.py Attributes: - __tablename__ (str): The name of the table in postgres pk (int): The primary key for the database src_id (str): The source channel for the listener dst_id (str): The destination channel for the listener """ __tablename__ = "listeners" + pk = bot.db.Column(bot.db.Integer, primary_key=True) src_id = bot.db.Column(bot.db.String) dst_id = bot.db.Column(bot.db.String) @@ -281,13 +274,13 @@ class Rule(bot.db.Model): Currently used in rules.py Attributes: - __tablename__ (str): The name of the table in postgres pk (int): The primary key for the database guild_id (str): The ID of the guild that these rules are for rules (str): The json representation of the rules """ __tablename__ = "guild_rules" + pk = bot.db.Column(bot.db.Integer, primary_key=True) guild_id = bot.db.Column(bot.db.String) rules = bot.db.Column(bot.db.String) @@ -297,7 +290,6 @@ class Votes(bot.db.Model): Currently used in voting.py Attributes: - __tablename__ (str): The name of the table in postgres vote_id (int): The primary key of the vote guild_id (str): The guild the vote belongs to message_id (str): The ID of the message the vote is in @@ -317,6 +309,7 @@ class Votes(bot.db.Model): """ __tablename__ = "voting" + vote_id = bot.db.Column(bot.db.Integer, primary_key=True) guild_id = bot.db.Column(bot.db.String) message_id = bot.db.Column(bot.db.String) diff --git a/techsupport_bot/ircrelay/irc.py b/techsupport_bot/ircrelay/irc.py index eaa1ff41..725f8d36 100644 --- a/techsupport_bot/ircrelay/irc.py +++ b/techsupport_bot/ircrelay/irc.py @@ -9,6 +9,7 @@ import threading from typing import Self +import commands import discord import ib3.auth import irc.bot @@ -40,13 +41,13 @@ class IRCBot(ib3.auth.SASL, irc.bot.SingleServerIRCBot): password (str): The password of the IRC bot account """ - irc_cog = None - loop = None - console = logging.getLogger("root") - IRC_BOLD = "" - connection = None - join_thread = None - ready = False + irc_cog: commands.relay.DiscordToIRC = None + loop: asyncio.AbstractEventLoop = None + console: logging.Logger = logging.getLogger("root") + IRC_BOLD: str = "" + connection: irc.client.ServerConnection = None + join_thread: threading.Timer = None + ready: bool = False def __init__( self: Self, diff --git a/techsupport_bot/tests/commands_tests/test_extensions_wyr.py b/techsupport_bot/tests/commands_tests/test_extensions_wyr.py index 7ea1a94e..d1649039 100644 --- a/techsupport_bot/tests/commands_tests/test_extensions_wyr.py +++ b/techsupport_bot/tests/commands_tests/test_extensions_wyr.py @@ -100,7 +100,7 @@ class Test_Get_Question: sample_resource (str): A set of same questions for doing unit tests """ - sample_resource = '"q1o1" || "q1o2"\n"q2o1" || "q2o2"' + sample_resource: str = '"q1o1" || "q1o2"\n"q2o1" || "q2o2"' def test_any_question(self: Self) -> None: """Ensure that get_question gets any question""" diff --git a/techsupport_bot/ui/application.py b/techsupport_bot/ui/application.py index 9ba674f3..8474a00a 100644 --- a/techsupport_bot/ui/application.py +++ b/techsupport_bot/ui/application.py @@ -17,14 +17,14 @@ class Application(discord.ui.Modal, title="Staff interest form"): reason (discord.ui.TextInput): The reason question for the application """ - background = discord.ui.TextInput( + background: discord.ui.TextInput = discord.ui.TextInput( label="Do you have any IT or programming experience?", style=discord.TextStyle.long, required=True, max_length=300, ) - reason = discord.ui.TextInput( + reason: discord.ui.TextInput = discord.ui.TextInput( label="Why do you want to help here?", style=discord.TextStyle.long, required=True, diff --git a/techsupport_bot/ui/appnotice.py b/techsupport_bot/ui/appnotice.py index 67db84cd..d35bb34b 100644 --- a/techsupport_bot/ui/appnotice.py +++ b/techsupport_bot/ui/appnotice.py @@ -14,7 +14,9 @@ class AppNotice(discord.ui.View): ICON (str): The Icon for the application reminder """ - ICON = "https://icon-icons.com/downloadimage.php?id=14692&root=80/PNG/256/&file=help_15418.png" + ICON: str = ( + "https://icon-icons.com/downloadimage.php?id=14692&root=80/PNG/256/&file=help_15418.png" + ) async def send(self: Self, channel: discord.abc.Messageable, message: str) -> None: """The entry point to this function, will send a message to the given channel