From 31fa5eb937fe5a4fa029b384d9b3de01143c1697 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Sun, 17 Dec 2023 03:11:51 -0500 Subject: [PATCH] fix(moderation): pylint fixes --- .forgejo/workflows/config/.pylintrc | 3 ++- moderation/database.py | 2 ++ moderation/embed_factory.py | 2 ++ moderation/moderation.py | 2 +- moderation/utils.py | 8 ++++++-- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.forgejo/workflows/config/.pylintrc b/.forgejo/workflows/config/.pylintrc index b336a0a..567675b 100644 --- a/.forgejo/workflows/config/.pylintrc +++ b/.forgejo/workflows/config/.pylintrc @@ -13,4 +13,5 @@ too-many-public-methods, too-many-statements, arguments-differ, - too-many-return-statements + too-many-return-statements, + import-outside-toplevel diff --git a/moderation/database.py b/moderation/database.py index 2099e66..f2ae277 100644 --- a/moderation/database.py +++ b/moderation/database.py @@ -1,3 +1,5 @@ +# pylint: disable=cyclic-import + import json import time from datetime import datetime diff --git a/moderation/embed_factory.py b/moderation/embed_factory.py index 2fd136f..c221493 100644 --- a/moderation/embed_factory.py +++ b/moderation/embed_factory.py @@ -1,3 +1,5 @@ +# pylint: disable=cyclic-import + from datetime import datetime, timedelta import humanize from discord import Color, Embed, Guild, Interaction, InteractionMessage diff --git a/moderation/moderation.py b/moderation/moderation.py index 0441eec..40df714 100644 --- a/moderation/moderation.py +++ b/moderation/moderation.py @@ -762,7 +762,7 @@ class Moderation(commands.Cog): cursor.execute(resolve_query, (json.dumps(changes), interaction.user.id, reason, case_dict['moderation_id'])) database.commit() - embed = await embed_factory('case', await self.bot.get_embed_color(None), interaction=interaction, case_dict=await self.fetch_case(case, interaction.guild.id)) + embed = await embed_factory('case', await self.bot.get_embed_color(None), interaction=interaction, case_dict=await fetch_case(case, interaction.guild.id)) await interaction.response.send_message(content=f"✅ Moderation #{case:,} resolved!", embed=embed) await log(interaction, case) diff --git a/moderation/utils.py b/moderation/utils.py index 0de3dd4..c61f04a 100644 --- a/moderation/utils.py +++ b/moderation/utils.py @@ -1,10 +1,11 @@ +# pylint: disable=cyclic-import + import json from typing import Union -from discord import Color, User, Member, Interaction, Guild +from discord import User, Member, Interaction, Guild from discord.errors import NotFound, Forbidden from redbot.core import commands from .config import config -from .database import connect, fetch_case async def check_conf(config_list: list): @@ -110,6 +111,8 @@ async def check_moddable( async def get_next_case_number(guild_id: str, cursor=None): """This method returns the next case number from the MySQL table for a specific guild.""" + from .database import connect + if not cursor: database = await connect() cursor = database.cursor() @@ -183,6 +186,7 @@ async def fetch_role_dict(interaction: Interaction, role_id: str): async def log(interaction: Interaction, moderation_id: int, resolved: bool = False): """This method sends a message to the guild's configured logging channel when an infraction takes place.""" from .embed_factory import embed_factory + from .database import fetch_case logging_channel_id = await config.guild(interaction.guild).log_channel() if logging_channel_id != " ":