From e236a66f78f68669823f199c772edca5099ebdb0 Mon Sep 17 00:00:00 2001 From: ajax146 <31014239+ajax146@users.noreply.github.com> Date: Tue, 16 Apr 2024 22:34:43 -0400 Subject: [PATCH 1/3] Fix all flake8 DCO024 issues --- techsupport_bot/commands/application.py | 9 ++++----- techsupport_bot/commands/factoids.py | 9 ++------- techsupport_bot/commands/members.py | 2 +- techsupport_bot/commands/modmail.py | 2 +- techsupport_bot/commands/role.py | 2 +- techsupport_bot/core/auxiliary.py | 1 - techsupport_bot/core/cogs.py | 22 +++++++++++----------- techsupport_bot/core/http.py | 12 +++++++++--- 8 files changed, 29 insertions(+), 30 deletions(-) diff --git a/techsupport_bot/commands/application.py b/techsupport_bot/commands/application.py index 70ed1009e..9da402503 100644 --- a/techsupport_bot/commands/application.py +++ b/techsupport_bot/commands/application.py @@ -596,11 +596,10 @@ async def build_application_embed( """This builds the embed that will be sent to staff Args: - applicant (discord.Member): The member who has applied - background (str): The answer to the background question - reason (str): The answer to the reason question - new (bool, Optional): If the application is new and the title should include new. - Defaults to True + guild (discord.Guild): The guild the user has applied to + application (bot.models.Applications): The database entry of the application + new (bool, optional): If the application is new and the title should + include new. Defaults to True. Returns: discord.Embed: The stylized embed ready to be show to people diff --git a/techsupport_bot/commands/factoids.py b/techsupport_bot/commands/factoids.py index f9fc838df..4a0bfa099 100644 --- a/techsupport_bot/commands/factoids.py +++ b/techsupport_bot/commands/factoids.py @@ -265,11 +265,6 @@ async def modify_factoid_call( Args: factoid (Factoid): Factoid to modify. - factoid_name (str, optional): New factoid name. Defaults to None. - message (str, optional): New factoid message. Defaults to None. - embed_config (str, optional): Whether the factoid has an embed set up. Defaults to None. - hidden (bool, optional): Whether the factoid is hidden. Defaults to None. - alias (str, optional): New parent factoid. Defaults to None. Raises: custom_errors.TooLongFactoidMessageError: @@ -657,7 +652,7 @@ async def delete_factoid( Args: ctx (commands.Context): Context to send the confirmation message to - factoid_name (CalledFactoid): The factoid to remove + called_factoid (CalledFactoid): The factoid to remove Returns: (bool): Whether the factoid was deleted @@ -816,7 +811,7 @@ async def send_to_irc( """Send a factoid to IRC channel, if it was called in a linked channel Args: - ctx (discord.abc.Messageable): The channel the factoid was sent in + channel (discord.abc.Messageable): The channel the factoid was sent in message (discord.Message): The message object of the invocation factoid_message (str): The text of the factoid to send """ diff --git a/techsupport_bot/commands/members.py b/techsupport_bot/commands/members.py index f5bed8974..b8f83331c 100644 --- a/techsupport_bot/commands/members.py +++ b/techsupport_bot/commands/members.py @@ -36,7 +36,7 @@ async def get_members_with_role( Args: ctx (command.Context): Used to return a message member_list (list): A list of members to parse - role (str): The role to check for + role_name (str): The role to check for """ # All roles are handled using a shorthand for loop because all # `.roles` attributes have lists of role objects, we want the names. diff --git a/techsupport_bot/commands/modmail.py b/techsupport_bot/commands/modmail.py index 9d9e71418..60a1933bc 100644 --- a/techsupport_bot/commands/modmail.py +++ b/techsupport_bot/commands/modmail.py @@ -772,7 +772,7 @@ async def log_closure( Args: thread (discord.Thread): The thread that got closed - user (int): The id of the person who created the thread, not an user object to + user_id (int): The id of the person who created the thread, not an user object to be able to include the ID even if the user leaves the guild log_channel (discord.TextChannel): The log channel to send the closure message to closed_by (discord.User): The person who closed the thread diff --git a/techsupport_bot/commands/role.py b/techsupport_bot/commands/role.py index 59b5f9e61..6fb86dc61 100644 --- a/techsupport_bot/commands/role.py +++ b/techsupport_bot/commands/role.py @@ -278,7 +278,7 @@ async def modify_roles( to the user. Any roles not on this list will be removed guild (discord.Guild): The guild to assign the roles in user (discord.Member): The member to assign roles to - resaon (str): The reason to add to the audit log + reason (str): The reason to add to the audit log interaction (discord.Interaction): The interaction to respond to """ added_roles = [] diff --git a/techsupport_bot/core/auxiliary.py b/techsupport_bot/core/auxiliary.py index cf2a11cb8..7bb987b3d 100644 --- a/techsupport_bot/core/auxiliary.py +++ b/techsupport_bot/core/auxiliary.py @@ -204,7 +204,6 @@ async def get_json_from_attachments( """Returns concatted JSON from a message's attachments. parameters: - ctx (discord.ext.Context): the context object for the message message (Message): the message object as_string (bool): True if the serialized JSON should be returned allow_failure (bool): True if an exception should be ignored when parsing attachments diff --git a/techsupport_bot/core/cogs.py b/techsupport_bot/core/cogs.py index 73b7e5893..59b44abb1 100644 --- a/techsupport_bot/core/cogs.py +++ b/techsupport_bot/core/cogs.py @@ -143,9 +143,9 @@ async def match( """Runs a boolean check on message content. parameters: - config (dict): the config associated with the context - ctx (context): the context object - content (str): the message content + _config (dict): the config associated with the context + _ctx (context): the context object + _content (str): the message content """ return True @@ -155,9 +155,9 @@ async def response( """Performs a response if the match is valid. parameters: - config (dict): the config associated with the context - ctx (context): the context object - content (str): the message content + _config (dict): the config associated with the context + _ctx (context): the context object + _content (str): the message content """ @@ -374,9 +374,9 @@ async def execute( """Runs sequentially after each wait method. parameters: - config (munch.Munch): the config object for the guild - guild (discord.Guild): the guild associated with the execution - target_channel (discord.Channel): the channel object to use + _config (munch.Munch): the config object for the guild + _guild (discord.Guild): the guild associated with the execution + _target_channel (discord.Channel): the channel object to use """ async def _default_wait(self) -> None: @@ -387,7 +387,7 @@ async def wait(self, _config: munch.Munch, _guild: discord.Guild) -> None: """The default wait method. parameters: - config (munch.Munch): the config object for the guild - guild (discord.Guild): the guild associated with the execution + _config (munch.Munch): the config object for the guild + _guild (discord.Guild): the guild associated with the execution """ await self._default_wait() diff --git a/techsupport_bot/core/http.py b/techsupport_bot/core/http.py index 7050e52f3..2186bee3a 100644 --- a/techsupport_bot/core/http.py +++ b/techsupport_bot/core/http.py @@ -79,7 +79,15 @@ def __init__(self, bot: bot.TechSupportBot) -> None: except AttributeError: print("No linx API URL found. Not rate limiting linx") - async def http_call(self, method, url, *args, **kwargs): + async def http_call( + self, + method, + url, + use_cache: bool = False, + get_raw_response: bool = False, + *args, + **kwargs, + ): """Makes an HTTP request. By default this returns JSON/dict with the status code injected. @@ -131,8 +139,6 @@ async def http_call(self, method, url, *args, **kwargs): url = url.replace(" ", "%20").replace("+", "%2b") method = method.lower() - use_cache = kwargs.pop("use_cache", False) - get_raw_response = kwargs.pop("get_raw_response", False) cache_key = url.lower() if kwargs.get("params"): From 60634e6708142bdc40b99c53e084bd7eb45fc4ef Mon Sep 17 00:00:00 2001 From: ajax146 <31014239+ajax146@users.noreply.github.com> Date: Tue, 16 Apr 2024 22:56:37 -0400 Subject: [PATCH 2/3] Maybe solve linting error --- techsupport_bot/core/http.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/techsupport_bot/core/http.py b/techsupport_bot/core/http.py index 2186bee3a..5b1366684 100644 --- a/techsupport_bot/core/http.py +++ b/techsupport_bot/core/http.py @@ -81,8 +81,8 @@ def __init__(self, bot: bot.TechSupportBot) -> None: async def http_call( self, - method, - url, + method: str, + url: str, use_cache: bool = False, get_raw_response: bool = False, *args, From d7ca22839ecc215c235856ff3c1ab44ebb9a0764 Mon Sep 17 00:00:00 2001 From: ajax146 <31014239+ajax146@users.noreply.github.com> Date: Tue, 16 Apr 2024 23:02:36 -0400 Subject: [PATCH 3/3] undo http call changes --- techsupport_bot/core/http.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/techsupport_bot/core/http.py b/techsupport_bot/core/http.py index 5b1366684..cc26592ca 100644 --- a/techsupport_bot/core/http.py +++ b/techsupport_bot/core/http.py @@ -79,15 +79,7 @@ def __init__(self, bot: bot.TechSupportBot) -> None: except AttributeError: print("No linx API URL found. Not rate limiting linx") - async def http_call( - self, - method: str, - url: str, - use_cache: bool = False, - get_raw_response: bool = False, - *args, - **kwargs, - ): + async def http_call(self, method: str, url: str, *args, **kwargs): """Makes an HTTP request. By default this returns JSON/dict with the status code injected. @@ -139,6 +131,8 @@ async def http_call( url = url.replace(" ", "%20").replace("+", "%2b") method = method.lower() + use_cache = kwargs.pop("use_cache", False) + get_raw_response = kwargs.pop("get_raw_response", False) cache_key = url.lower() if kwargs.get("params"):