fix(repo): ruff fixes / removing pylint exceptions
All checks were successful
Actions / Lint Code (Ruff) (push) Successful in 6s
Actions / Build Documentation (MkDocs) (push) Successful in 25s

This commit is contained in:
Seaswimmer 2024-02-14 11:04:26 -05:00
parent e34d621e6d
commit 858a1bae8a
Signed by: cswimr
GPG key ID: B8953EC01E5C4063
12 changed files with 51 additions and 56 deletions

View file

@ -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):

View file

@ -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)

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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,

View file

@ -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(

View file

@ -1,5 +1,3 @@
# pylint: disable=cyclic-import
import json
from datetime import timedelta as td
from typing import Union

View file

@ -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}")

View file

@ -65,7 +65,7 @@ exclude = [
]
# Same as Black.
line-length = 300
line-length = 320
indent-width = 4
# Assume Python 3.11