From ce57755eee00feacf391ef518dfcf1157303e7f6 Mon Sep 17 00:00:00 2001 From: kku Date: Fri, 27 Dec 2024 22:23:41 +0100 Subject: [PATCH] Improved type-hinting for loggers and removed legacy --- classes/holo_user.py | 8 ++------ cogs/admin.py | 3 ++- cogs/analytics.py | 3 ++- cogs/custom_channels.py | 3 ++- cogs/fun.py | 3 ++- cogs/logger.py | 3 ++- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/classes/holo_user.py b/classes/holo_user.py index 0ebb2a9..508b8db 100644 --- a/classes/holo_user.py +++ b/classes/holo_user.py @@ -1,4 +1,5 @@ import logging +from logging import Logger from typing import Any, Dict from bson import ObjectId @@ -8,7 +9,7 @@ from libbot.utils import config_get from errors import UserNotFoundError from modules.database import col_warnings, sync_col_users, sync_col_warnings, col_users -logger = logging.getLogger(__name__) +logger: Logger = logging.getLogger(__name__) class HoloUser: @@ -123,8 +124,3 @@ class HoloUser: return True return False - - # def purge(self) -> None: - # """Completely remove data from database. Will not remove transactions logs and warnings.""" - # col_users.delete_one(filter={"_id": self.db_id}) - # self.unauthorize() diff --git a/cogs/admin.py b/cogs/admin.py index d6036aa..2d226a9 100644 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -1,5 +1,6 @@ import logging import sys +from logging import Logger from discord import ( ApplicationContext, @@ -20,7 +21,7 @@ from modules.scheduler import scheduler from modules.utils_sync import guild_name from modules.waifu_pics import waifu_pics -logger = logging.getLogger(__name__) +logger: Logger = logging.getLogger(__name__) class Admin(commands.Cog): diff --git a/cogs/analytics.py b/cogs/analytics.py index b3a27c7..af5f951 100644 --- a/cogs/analytics.py +++ b/cogs/analytics.py @@ -1,4 +1,5 @@ import logging +from logging import Logger from typing import Dict, List, Any from discord import Cog, Message @@ -7,7 +8,7 @@ from discord.ext import commands from classes.holo_bot import HoloBot from modules.database import col_analytics -logger = logging.getLogger(__name__) +logger: Logger = logging.getLogger(__name__) class Analytics(commands.Cog): diff --git a/cogs/custom_channels.py b/cogs/custom_channels.py index 6a1651b..328ca08 100644 --- a/cogs/custom_channels.py +++ b/cogs/custom_channels.py @@ -1,4 +1,5 @@ import logging +from logging import Logger from typing import Any, Dict from discord import ApplicationContext, Embed, option, TextChannel, Role @@ -14,7 +15,7 @@ from enums import Color from modules.database import col_users from modules.utils_sync import guild_name -logger = logging.getLogger(__name__) +logger: Logger = logging.getLogger(__name__) class CustomChannels(commands.Cog): diff --git a/cogs/fun.py b/cogs/fun.py index bb2bc58..0de5956 100644 --- a/cogs/fun.py +++ b/cogs/fun.py @@ -1,4 +1,5 @@ import logging +from logging import Logger from discord import ApplicationContext, Embed, User, option, slash_command from discord.ext import commands @@ -8,7 +9,7 @@ from classes.holo_bot import HoloBot from modules.utils_sync import guild_name from modules.waifu_pics import waifu_pics -logger = logging.getLogger(__name__) +logger: Logger = logging.getLogger(__name__) class Fun(commands.Cog): diff --git a/cogs/logger.py b/cogs/logger.py index 54201e2..66904a4 100644 --- a/cogs/logger.py +++ b/cogs/logger.py @@ -1,4 +1,5 @@ import logging +from logging import Logger from typing import Dict, Any from discord import Member, Message, TextChannel, MessageType @@ -9,7 +10,7 @@ from libbot.utils import config_get from classes.holo_bot import HoloBot from modules.database import col_users -logger = logging.getLogger(__name__) +logger: Logger = logging.getLogger(__name__) class Logger(commands.Cog):