From 499cfbe8a9ddb3e2a4e9afcaa403a2f56dae478e Mon Sep 17 00:00:00 2001 From: Seaswimmer Date: Mon, 3 Jun 2024 00:55:09 -0400 Subject: [PATCH] misc(aurora): use tuples instead of lists --- aurora/models/moderation.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/aurora/models/moderation.py b/aurora/models/moderation.py index 17a48f5..2e5fd5f 100644 --- a/aurora/models/moderation.py +++ b/aurora/models/moderation.py @@ -2,7 +2,7 @@ import json import sqlite3 from datetime import datetime, timedelta from time import time -from typing import Dict, Iterable, List, Optional, Union +from typing import Dict, Iterable, List, Optional, Tuple, Union import discord from discord import NotFound @@ -202,7 +202,7 @@ class Moderation(AuroraGuildModel): return cls.from_dict(bot=bot, data=case) @classmethod - def execute(cls, bot: Red, guild_id: int, query: str, parameters: tuple | None = None) -> List["Moderation"]: + def execute(cls, bot: Red, guild_id: int, query: str, parameters: tuple | None = None) -> Tuple["Moderation"]: from ..utilities.database import connect if not parameters: parameters = () @@ -218,8 +218,8 @@ class Moderation(AuroraGuildModel): case = cls.from_result(bot=bot, result=result, guild_id=guild_id) if case.moderation_id != 0: cases.append(case) - return cases - return [] + return tuple(iterable=cases) + return () @classmethod def from_sql(cls, bot: Red, moderation_id: int, guild_id: int) -> "Moderation": @@ -234,7 +234,7 @@ class Moderation(AuroraGuildModel): raise ValueError(f"Case {moderation_id} not found in moderation_{guild_id}!") @classmethod - def find_by_target(cls, bot: Red, guild_id: int, target: int, types: list | None = None) -> List["Moderation"]: + def find_by_target(cls, bot: Red, guild_id: int, target: int, types: list | None = None) -> Tuple["Moderation"]: query = f"SELECT * FROM moderation_{guild_id} WHERE target_id = ?" if types: query += f" AND moderation_type IN ({', '.join(['?' for _ in types])})" @@ -243,7 +243,7 @@ class Moderation(AuroraGuildModel): return cls.execute(bot=bot, guild_id=guild_id, query=query, parameters=(target, *types) if types else (target,)) @classmethod - def find_by_moderator(cls, bot: Red, guild_id: int, moderator: int, types: list | None = None) -> List["Moderation"]: + def find_by_moderator(cls, bot: Red, guild_id: int, moderator: int, types: list | None = None) -> Tuple["Moderation"]: query = f"SELECT * FROM moderation_{guild_id} WHERE moderator_id = ?" if types: query += f" AND moderation_type IN ({', '.join(['?' for _ in types])})" @@ -252,7 +252,7 @@ class Moderation(AuroraGuildModel): return cls.execute(bot=bot, guild_id=guild_id, query=query, parameters=(moderator, *types) if types else (moderator,)) @classmethod - def get_all_cases(cls, bot: Red, guild_id: int, types: list | None = None) -> List["Moderation"]: + def get_all_cases(cls, bot: Red, guild_id: int, types: list | None = None) -> Tuple["Moderation"]: query = f"SELECT * FROM moderation_{guild_id}" if types: query += f" WHERE moderation_type IN ({', '.join(['?' for _ in types])})"