From 850ddf15a6bc222a62778ffbcdbb6f9240131b37 Mon Sep 17 00:00:00 2001 From: cswimr Date: Sat, 25 Jan 2025 22:11:37 +0000 Subject: [PATCH] fix(aurora): improve typehints in the `Type` model --- aurora/models/type.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/aurora/models/type.py b/aurora/models/type.py index b510e45..7bc113a 100644 --- a/aurora/models/type.py +++ b/aurora/models/type.py @@ -1,5 +1,5 @@ from abc import ABC, abstractmethod -from typing import Any, Dict, Tuple +from typing import TYPE_CHECKING, Any, Dict, Tuple from class_registry import ClassRegistry from class_registry.base import AutoRegister @@ -7,10 +7,13 @@ from discord import Interaction, Member, User from discord.abc import Messageable from redbot.core import commands +if TYPE_CHECKING: + from .moderation import Moderation + type_registry: Dict["str", "Type"] = ClassRegistry(attr_name="key", unique=True) -class Type(AutoRegister(type_registry), ABC): +class Type(AutoRegister(registry=type_registry), ABC): """This is a base class for moderation types. Attributes: @@ -65,7 +68,7 @@ class Type(AutoRegister(type_registry), ABC): raise NotImplementedError @classmethod - async def resolve_handler(cls, moderation, reason: str) -> Tuple[bool, str]: # pylint: disable=unused-argument + async def resolve_handler(cls, moderation: "Moderation", reason: str) -> Tuple[bool, str]: # pylint: disable=unused-argument """This method should be overridden by any resolvable child classes, but should retain the same keyword arguments. If your moderation type should not be resolvable, do not override this. @@ -76,7 +79,7 @@ class Type(AutoRegister(type_registry), ABC): raise NotImplementedError @classmethod - async def expiry_handler(cls, moderation) -> int: # pylint: disable=unused-argument + async def expiry_handler(cls, moderation: "Moderation") -> int: # pylint: disable=unused-argument """This method should be overridden by any expirable child classes, but should retain the same keyword arguments and return an integer. If your moderation type should not expire, do not override this, but also do not set an `end_timestamp` when you log your moderation. @@ -86,7 +89,7 @@ class Type(AutoRegister(type_registry), ABC): raise NotImplementedError @classmethod - async def duration_edit_handler(cls, interaction: Interaction, old_moderation, new_moderation) -> bool: # pylint: disable=unused-argument + async def duration_edit_handler(cls, interaction: Interaction, old_moderation: "Moderation", new_moderation: "Moderation") -> bool: # pylint: disable=unused-argument """This method should be overridden by any child classes with editable durations, but should retain the same keyword arguments and should return True if the duration was successfully modified, or False if it was not. If your moderation type's duration should not be editable, do not override this.