From 858a1bae8a61621d78b9e6260dfb3c2a14207e97 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Wed, 14 Feb 2024 11:04:26 -0500 Subject: [PATCH] fix(repo): ruff fixes / removing pylint exceptions --- aurora/aurora.py | 4 ++-- aurora/importers/aurora.py | 7 +++---- aurora/importers/galacticbot.py | 5 ++--- aurora/menus/addrole.py | 10 ++++++---- aurora/menus/guild.py | 22 ++++++++++++---------- aurora/menus/immune.py | 10 ++++++---- aurora/menus/overrides.py | 12 +++++++----- aurora/utilities/database.py | 7 ++----- aurora/utilities/factory.py | 9 ++------- aurora/utilities/utils.py | 2 -- backup/backup.py | 17 ++++++++--------- pyproject.toml | 2 +- 12 files changed, 51 insertions(+), 56 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index f6d9323..3053484 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -84,7 +84,7 @@ class Aurora(commands.Cog): self.bot = bot register_config(config) disable_dateutil() - self.handle_expiry.start() # pylint: disable=no-member + self.handle_expiry.start() async def cog_load(self): """This method prepares the database schema for all of the guilds the bot is currently in.""" @@ -99,7 +99,7 @@ class Aurora(commands.Cog): return async def cog_unload(self): - self.handle_expiry.cancel() # pylint: disable=no-member + self.handle_expiry.cancel() @commands.Cog.listener("on_guild_join") async def db_generate_guild_join(self, guild: discord.Guild): diff --git a/aurora/importers/aurora.py b/aurora/importers/aurora.py index d644ddd..337f5a4 100644 --- a/aurora/importers/aurora.py +++ b/aurora/importers/aurora.py @@ -9,7 +9,6 @@ from redbot.core.utils.chat_formatting import box, warning from ..utilities.database import connect, create_guild_table, mysql_log -# pylint: disable=duplicate-code class ImportAuroraView(ui.View): def __init__(self, timeout, ctx, message): super().__init__() @@ -19,7 +18,7 @@ class ImportAuroraView(ui.View): @ui.button(label="Yes", style=ButtonStyle.success) async def import_button_y( self, interaction: Interaction, button: ui.Button - ): # pylint: disable=unused-argument + ): await self.message.delete() await interaction.response.send_message( "Deleting original table...", ephemeral=True @@ -41,7 +40,7 @@ class ImportAuroraView(ui.View): await interaction.edit_original_response(content="Importing moderations...") file = await self.ctx.message.attachments[0].read() - data: [dict] = sorted(json.loads(file), key=lambda x: x["moderation_id"]) + data: list[dict] = sorted(json.loads(file), key=lambda x: x["moderation_id"]) user_mod_types = ["NOTE", "WARN", "MUTE", "UNMUTE", "KICK", "BAN", "UNBAN"] @@ -108,7 +107,7 @@ class ImportAuroraView(ui.View): @ui.button(label="No", style=ButtonStyle.danger) async def import_button_n( self, interaction: Interaction, button: ui.Button - ): # pylint: disable=unused-argument + ): await self.message.edit(content="Import cancelled.", view=None) await self.message.delete(10) await self.ctx.message.delete(10) diff --git a/aurora/importers/galacticbot.py b/aurora/importers/galacticbot.py index 29699e3..d5cb66c 100644 --- a/aurora/importers/galacticbot.py +++ b/aurora/importers/galacticbot.py @@ -8,7 +8,6 @@ from redbot.core.utils.chat_formatting import box, warning from ..utilities.database import connect, create_guild_table, mysql_log -# pylint: disable=duplicate-code class ImportGalacticBotView(ui.View): def __init__(self, timeout, ctx, message): super().__init__() @@ -18,7 +17,7 @@ class ImportGalacticBotView(ui.View): @ui.button(label="Yes", style=ButtonStyle.success) async def import_button_y( self, interaction: Interaction, button: ui.Button - ): # pylint: disable=unused-argument + ): await self.message.delete() await interaction.response.send_message( "Deleting original table...", ephemeral=True @@ -151,7 +150,7 @@ class ImportGalacticBotView(ui.View): @ui.button(label="No", style=ButtonStyle.danger) async def import_button_n( self, interaction: Interaction, button: ui.Button - ): # pylint: disable=unused-argument + ): await self.message.edit(content="Import cancelled.", view=None) await self.message.delete(10) await self.ctx.message.delete(10) diff --git a/aurora/menus/addrole.py b/aurora/menus/addrole.py index c792566..75c8cce 100644 --- a/aurora/menus/addrole.py +++ b/aurora/menus/addrole.py @@ -1,9 +1,11 @@ -from discord import ButtonStyle, ui, Interaction +from discord import ButtonStyle, Interaction, ui from redbot.core import commands from redbot.core.utils.chat_formatting import error -from aurora.utilities.factory import addrole_embed from aurora.utilities.config import config +from aurora.utilities.factory import addrole_embed + + class Addrole(ui.View): def __init__(self, ctx: commands.Context): @@ -25,7 +27,7 @@ class Addrole(ui.View): await interaction.message.edit(embed=await addrole_embed(self.ctx)) @ui.button(label="Clear", style=ButtonStyle.red, row=1) - async def clear(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument + async def clear(self, interaction: Interaction, button: ui.Button): if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator: await interaction.response.send_message(error("You must have the manage guild permission to clear the guild's addrole whitelist."), ephemeral=True) return @@ -34,7 +36,7 @@ class Addrole(ui.View): await interaction.message.edit(embed=await addrole_embed(self.ctx)) @ui.button(label="Close", style=ButtonStyle.gray) - async def close(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument + async def close(self, interaction: Interaction, button: ui.Button): if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator: await interaction.response.send_message(error("You can't do that!"), ephemeral=True) return diff --git a/aurora/menus/guild.py b/aurora/menus/guild.py index 7d14ebc..8a2e2c9 100644 --- a/aurora/menus/guild.py +++ b/aurora/menus/guild.py @@ -1,9 +1,11 @@ -from discord import ui, ButtonStyle, Interaction +from discord import ButtonStyle, Interaction, ui from redbot.core import commands +from aurora.utilities.config import config from aurora.utilities.factory import guild_embed from aurora.utilities.utils import create_pagesize_options -from aurora.utilities.config import config + + class Guild(ui.View): def __init__(self, ctx: commands.Context): @@ -11,7 +13,7 @@ class Guild(ui.View): self.ctx = ctx @ui.button(label="Show Moderator", style=ButtonStyle.green, row=0) - async def show_moderator(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument + async def show_moderator(self, interaction: Interaction, button: ui.Button): if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator: await interaction.response.send_message("You must have the manage guild permission to change this setting.", ephemeral=True) return @@ -21,7 +23,7 @@ class Guild(ui.View): await interaction.message.edit(embed=await guild_embed(self.ctx)) @ui.button(label="Use Discord Permissions", style=ButtonStyle.green, row=0) - async def use_discord_permissions(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument + async def use_discord_permissions(self, interaction: Interaction, button: ui.Button): if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator: await interaction.response.send_message("You must have the manage guild permission to change this setting.", ephemeral=True) return @@ -31,7 +33,7 @@ class Guild(ui.View): await interaction.message.edit(embed=await guild_embed(self.ctx)) @ui.button(label="Ignore Modlog", style=ButtonStyle.green, row=0) - async def ignore_modlog(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument + async def ignore_modlog(self, interaction: Interaction, button: ui.Button): if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator: await interaction.response.send_message("You must have the manage guild permission to change this setting.", ephemeral=True) return @@ -41,7 +43,7 @@ class Guild(ui.View): await interaction.message.edit(embed=await guild_embed(self.ctx)) @ui.button(label="Ignore Other Bots", style=ButtonStyle.green, row=0) - async def ignore_other_bots(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument + async def ignore_other_bots(self, interaction: Interaction, button: ui.Button): if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator: await interaction.response.send_message("You must have the manage guild permission to change this setting.", ephemeral=True) return @@ -51,7 +53,7 @@ class Guild(ui.View): await interaction.message.edit(embed=await guild_embed(self.ctx)) @ui.button(label="DM Users", style=ButtonStyle.green, row=1) - async def dm_users(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument + async def dm_users(self, interaction: Interaction, button: ui.Button): if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator: await interaction.response.send_message("You must have the manage guild permission to change this setting.", ephemeral=True) return @@ -61,7 +63,7 @@ class Guild(ui.View): await interaction.message.edit(embed=await guild_embed(self.ctx)) @ui.button(label="Auto Evidence Format", style=ButtonStyle.green, row=1) - async def auto_evidenceformat(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument + async def auto_evidenceformat(self, interaction: Interaction, button: ui.Button): if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator: await interaction.response.send_message("You must have the manage guild permission to change this setting.", ephemeral=True) return @@ -71,7 +73,7 @@ class Guild(ui.View): await interaction.message.edit(embed=await guild_embed(self.ctx)) @ui.button(label="Ephemeral", style=ButtonStyle.green, row=1) - async def ephemeral(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument + async def ephemeral(self, interaction: Interaction, button: ui.Button): if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator: await interaction.response.send_message("You must have the manage guild permission to change this setting.", ephemeral=True) return @@ -81,7 +83,7 @@ class Guild(ui.View): await interaction.message.edit(embed=await guild_embed(self.ctx)) @ui.button(label="History Inline", style=ButtonStyle.green, row=1) - async def inline(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument + async def inline(self, interaction: Interaction, button: ui.Button): if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator: await interaction.response.send_message("You must have the manage guild permission to change this setting.", ephemeral=True) return diff --git a/aurora/menus/immune.py b/aurora/menus/immune.py index e48aba8..df509ef 100644 --- a/aurora/menus/immune.py +++ b/aurora/menus/immune.py @@ -1,9 +1,11 @@ -from discord import ButtonStyle, ui, Interaction +from discord import ButtonStyle, Interaction, ui from redbot.core import commands from redbot.core.utils.chat_formatting import error -from aurora.utilities.factory import immune_embed from aurora.utilities.config import config +from aurora.utilities.factory import immune_embed + + class Immune(ui.View): def __init__(self, ctx: commands.Context): @@ -26,7 +28,7 @@ class Immune(ui.View): await interaction.message.edit(embed=await immune_embed(self.ctx)) @ui.button(label="Clear", style=ButtonStyle.red, row=1) - async def clear(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument + async def clear(self, interaction: Interaction, button: ui.Button): if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator: await interaction.response.send_message(error("You must have the manage guild permission to clear the guild's immune roles."), ephemeral=True) return @@ -35,7 +37,7 @@ class Immune(ui.View): await interaction.message.edit(embed=await immune_embed(self.ctx)) @ui.button(label="Close", style=ButtonStyle.gray) - async def close(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument + async def close(self, interaction: Interaction, button: ui.Button): if not interaction.user.guild_permissions.manage_guild and not interaction.user.guild_permissions.administrator: await interaction.response.send_message(error("You can't do that!"), ephemeral=True) return diff --git a/aurora/menus/overrides.py b/aurora/menus/overrides.py index 4475706..c0060ba 100644 --- a/aurora/menus/overrides.py +++ b/aurora/menus/overrides.py @@ -1,9 +1,11 @@ -from discord import ui, ButtonStyle, Interaction +from discord import ButtonStyle, Interaction, ui from redbot.core import commands +from aurora.utilities.config import config from aurora.utilities.factory import overrides_embed from aurora.utilities.utils import create_pagesize_options -from aurora.utilities.config import config + + class Overrides(ui.View): def __init__(self, ctx: commands.Context): @@ -11,7 +13,7 @@ class Overrides(ui.View): self.ctx = ctx @ui.button(label="Auto Evidence Format", style=ButtonStyle.green, row=0) - async def auto_evidenceformat(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument + async def auto_evidenceformat(self, interaction: Interaction, button: ui.Button): if self.ctx.author != interaction.user: await interaction.response.send_message("You cannot change this setting for other users.", ephemeral=True) return @@ -26,7 +28,7 @@ class Overrides(ui.View): await interaction.message.edit(embed=await overrides_embed(self.ctx)) @ui.button(label="Ephemeral", style=ButtonStyle.green, row=0) - async def ephemeral(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument + async def ephemeral(self, interaction: Interaction, button: ui.Button): if self.ctx.author != interaction.user: await interaction.response.send_message("You cannot change this setting for other users.", ephemeral=True) return @@ -41,7 +43,7 @@ class Overrides(ui.View): await interaction.message.edit(embed=await overrides_embed(self.ctx)) @ui.button(label="Inline", style=ButtonStyle.green, row=0) - async def inline(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument + async def inline(self, interaction: Interaction, button: ui.Button): if self.ctx.author != interaction.user: await interaction.response.send_message("You cannot change this setting for other users.", ephemeral=True) return diff --git a/aurora/utilities/database.py b/aurora/utilities/database.py index 9acb4c1..689af67 100644 --- a/aurora/utilities/database.py +++ b/aurora/utilities/database.py @@ -1,5 +1,3 @@ -# pylint: disable=cyclic-import - import json import sqlite3 import time @@ -87,8 +85,8 @@ async def create_guild_table(guild: Guild): "NULL", "NULL", 0, - json.dumps([]), # pylint: disable=dangerous-default-value - json.dumps({}), # pylint: disable=dangerous-default-value + json.dumps([]), + json.dumps({}), ) cursor.execute(insert_query, insert_values) @@ -104,7 +102,6 @@ async def create_guild_table(guild: Guild): database.close() -# pylint: disable=dangerous-default-value async def mysql_log( guild_id: str, author_id: str, diff --git a/aurora/utilities/factory.py b/aurora/utilities/factory.py index c9df7e0..18e5bd3 100644 --- a/aurora/utilities/factory.py +++ b/aurora/utilities/factory.py @@ -1,18 +1,13 @@ -# pylint: disable=cyclic-import - from datetime import datetime, timedelta from typing import Union import humanize -from discord import (Color, Embed, Guild, Interaction, InteractionMessage, - Member, Role, User) +from discord import Color, Embed, Guild, Interaction, InteractionMessage, Member, Role, User from redbot.core import commands from redbot.core.utils.chat_formatting import bold, box, error, warning from aurora.utilities.config import config -from aurora.utilities.utils import (fetch_channel_dict, fetch_user_dict, - get_bool_emoji, get_next_case_number, - get_pagesize_str) +from aurora.utilities.utils import fetch_channel_dict, fetch_user_dict, get_bool_emoji, get_next_case_number, get_pagesize_str async def message_factory( diff --git a/aurora/utilities/utils.py b/aurora/utilities/utils.py index 2e5174c..24dbe34 100644 --- a/aurora/utilities/utils.py +++ b/aurora/utilities/utils.py @@ -1,5 +1,3 @@ -# pylint: disable=cyclic-import - import json from datetime import timedelta as td from typing import Union diff --git a/backup/backup.py b/backup/backup.py index 60b5aa0..0592741 100644 --- a/backup/backup.py +++ b/backup/backup.py @@ -17,7 +17,6 @@ from redbot.core.bot import Red from redbot.core.utils.chat_formatting import error, text_to_file -# pylint: disable=protected-access class Backup(commands.Cog): """A utility to make reinstalling repositories and cogs after migrating the bot far easier.""" @@ -130,7 +129,7 @@ class Backup(commands.Cog): try: repository = await downloader._repo_manager.add_repo( url, name, branch - ) # pylint: disable=protected-access + ) repo_s.append( f"Added repository {name} from {url} on branch {branch}." ) @@ -142,7 +141,7 @@ class Backup(commands.Cog): repo_e.append(f"Repository {name} already exists.") repository = downloader._repo_manager.get_repo( name - ) # pylint: disable=protected-access + ) self.logger.debug("Repository %s already exists", name) # This is commented out because errors.AuthenticationError is not yet implemented in Red 3.5.5's Downloader cog. @@ -200,7 +199,7 @@ class Backup(commands.Cog): await ctx.bot.remove_loaded_package(cog) await downloader._delete_cog( poss_installed_path - ) # pylint: disable=protected-access + ) uninstall_s.append(f"Uninstalled {cog}") self.logger.debug("Uninstalled %s", cog) else: @@ -208,7 +207,7 @@ class Backup(commands.Cog): self.logger.warning("Failed to uninstall %s", cog) await downloader._remove_from_installed( cog_modules - ) # pylint: disable=protected-access + ) for cog in cogs: cog_name = cog["name"] @@ -229,14 +228,14 @@ class Backup(commands.Cog): await downloader._filter_incorrect_cogs_by_names( repository, [cog_name] ) - ) # pylint: disable=protected-access + ) if not cogs_c: install_e.append(message) self.logger.error(message) continue failed_reqs = await downloader._install_requirements( cogs_c - ) # pylint: disable=protected-access + ) if failed_reqs: install_e.append( f"Failed to install {cog_name} due to missing requirements: {failed_reqs}" @@ -250,7 +249,7 @@ class Backup(commands.Cog): installed_cogs, failed_cogs = await downloader._install_cogs( cogs_c - ) # pylint: disable=protected-access + ) if repository.available_libraries: installed_libs, failed_libs = ( @@ -271,7 +270,7 @@ class Backup(commands.Cog): installed_cogs + installed_libs if installed_libs else installed_cogs - ) # pylint: disable=protected-access + ) if installed_cogs: installed_cog_name = installed_cogs[0].name install_s.append(f"Installed {installed_cog_name}") diff --git a/pyproject.toml b/pyproject.toml index 96c9152..4371aac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,7 +65,7 @@ exclude = [ ] # Same as Black. -line-length = 300 +line-length = 320 indent-width = 4 # Assume Python 3.11