fix(aurora): pylint fixes
All checks were successful
Actions / Build Documentation (MkDocs) (pull_request) Successful in 27s
Actions / Lint Code (Ruff & Pylint) (pull_request) Successful in 43s

This commit is contained in:
Seaswimmer 2024-05-06 16:47:21 -04:00
parent 09471a4027
commit ac8cefd779
Signed by: cswimr
GPG key ID: 5D671B5D03D65A7F
6 changed files with 27 additions and 29 deletions

View file

@ -20,7 +20,8 @@ from redbot.core import app_commands, commands, data_manager
from redbot.core.app_commands import Choice
from redbot.core.bot import Red
from redbot.core.commands.converter import parse_relativedelta, parse_timedelta
from redbot.core.utils.chat_formatting import box, error, humanize_list, humanize_timedelta, warning
from redbot.core.utils.chat_formatting import (box, error, humanize_list,
humanize_timedelta, warning)
from aurora.importers.aurora import ImportAuroraView
from aurora.importers.galacticbot import ImportGalacticBotView
@ -31,10 +32,17 @@ from aurora.menus.overrides import Overrides
from aurora.models import Change, Moderation
from aurora.utilities.config import config, register_config
from aurora.utilities.database import connect, create_guild_table
from aurora.utilities.factory import addrole_embed, case_factory, changes_factory, evidenceformat_factory, guild_embed, immune_embed, message_factory, overrides_embed
from aurora.utilities.factory import (addrole_embed, case_factory,
changes_factory, evidenceformat_factory,
guild_embed, immune_embed,
message_factory, overrides_embed)
from aurora.utilities.json import dump
from aurora.utilities.logger import logger
from aurora.utilities.utils import check_moddable, check_permissions, get_footer_image, log, send_evidenceformat, timedelta_from_relativedelta
from aurora.utilities.utils import (check_moddable, check_permissions,
get_footer_image, log, send_evidenceformat,
timedelta_from_relativedelta)
class Aurora(commands.Cog):
"""Aurora is a fully-featured moderation system.
@ -1327,9 +1335,7 @@ class Aurora(commands.Cog):
embed=embed, ephemeral=ephemeral
)
elif evidenceformat:
content = await evidenceformat_factory(
interaction=interaction, moderation=mod
)
content = await evidenceformat_factory(moderation=mod)
await interaction.response.send_message(
content=content, ephemeral=ephemeral
)

View file

@ -100,13 +100,13 @@ class ImportGalacticBotView(ui.View):
if resolved_timestamp is None:
resolved_timestamp = timestamp
changes = [
Change.from_dict({
Change.from_dict(interaction.client, {
"type": "ORIGINAL",
"reason": case["reason"],
"user_id": case["executor"],
"timestamp": timestamp,
}),
Change.from_dict({
Change.from_dict(interaction.client, {
"type": "RESOLVE",
"reason": resolved_reason,
"user_id": resolved_by,

View file

@ -19,7 +19,7 @@ class AuroraBaseModel(BaseModel):
bot: Red
def to_json(self, indent: int = None, file: Any = None, **kwargs):
from aurora.utilities.json import dump, dumps
from aurora.utilities.json import dump, dumps # pylint: disable=cyclic-import
return dump(self.model_dump(exclude={"bot"}), file, indent=indent, **kwargs) if file else dumps(self.model_dump(exclude={"bot"}), indent=indent, **kwargs)
class AuroraGuildModel(AuroraBaseModel):
@ -27,7 +27,7 @@ class AuroraGuildModel(AuroraBaseModel):
guild_id: int
def to_json(self, indent: int = None, file: Any = None, **kwargs):
from aurora.utilities.json import dump, dumps
from aurora.utilities.json import dump, dumps # pylint: disable=cyclic-import
return dump(self.model_dump(exclude={"bot", "guild_id"}), file, indent=indent, **kwargs) if file else dumps(self.model_dump(exclude={"bot", "guild_id"}), indent=indent, **kwargs)
class Moderation(AuroraGuildModel):
@ -66,8 +66,7 @@ class Moderation(AuroraGuildModel):
async def get_target(self) -> Union["PartialUser", "PartialChannel"]:
if self.target_type == "USER":
return await PartialUser.from_id(self.bot, self.target_id)
else:
return await PartialChannel.from_id(self.bot, self.target_id)
return await PartialChannel.from_id(self.bot, self.target_id)
async def get_resolved_by(self) -> Optional["PartialUser"]:
if self.resolved_by:
@ -264,10 +263,7 @@ class Moderation(AuroraGuildModel):
end_timestamp = None
if not expired:
if timestamp > end_timestamp:
expired = True
else:
expired = False
expired = bool(timestamp > end_timestamp)
if reason == "NULL":
reason = None
@ -422,7 +418,7 @@ class PartialChannel(AuroraGuildModel):
@property
def mention(self):
if self.name == "Deleted Channel" or self.name == "Forbidden Channel":
if self.name in ["Deleted Channel", "Forbidden Channel"]:
return self.name
return f"<#{self.id}>"
@ -448,7 +444,7 @@ class PartialRole(AuroraGuildModel):
@property
def mention(self):
if self.name == "Deleted Role" or self.name == "Forbidden Role":
if self.name in ["Deleted Role", "Forbidden Role"]:
return self.name
return f"<@&{self.id}>"

View file

@ -2,16 +2,13 @@
from datetime import datetime, timedelta
from typing import Union
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,
humanize_timedelta, warning)
from redbot.core.utils.chat_formatting import bold, box, error, humanize_timedelta, warning
from aurora.models import Moderation, PartialUser
from aurora.utilities.config import config
from aurora.utilities.utils import (get_bool_emoji, get_next_case_number,
get_pagesize_str)
from aurora.utilities.utils import get_bool_emoji, get_next_case_number, get_pagesize_str
async def message_factory(
@ -261,7 +258,7 @@ async def changes_factory(interaction: Interaction, moderation: Moderation) -> E
return embed
async def evidenceformat_factory(interaction: Interaction, moderation: Moderation) -> str:
async def evidenceformat_factory(moderation: Moderation) -> str:
"""This function creates a codeblock in evidence format from set parameters.
Args:

View file

@ -3,7 +3,6 @@ from datetime import datetime, timedelta
from redbot.core.bot import Red
from aurora.models import AuroraBaseModel

View file

@ -133,7 +133,7 @@ async def log(interaction: Interaction, moderation_id: int, resolved: bool = Fal
logging_channel = interaction.guild.get_channel(logging_channel_id)
try:
moderation = Moderation.from_sql(interaction.client, moderation_id)
moderation = Moderation.from_sql(interaction.client, moderation_id, interaction.guild_id)
embed = await log_factory(
interaction=interaction, moderation=moderation, resolved=resolved
)
@ -158,8 +158,8 @@ async def send_evidenceformat(interaction: Interaction, moderation_id: int) -> N
if send_evidence_bool is False:
return
moderation = Moderation.from_sql(interaction.client, moderation_id)
content = await evidenceformat_factory(interaction=interaction, moderation=moderation)
moderation = Moderation.from_sql(interaction.client, moderation_id, interaction.guild.id)
content = await evidenceformat_factory(moderation=moderation)
await interaction.followup.send(content=content, ephemeral=True)