fix(aurora): improve typehints in the Type model
Some checks failed
Actions / Build Documentation (MkDocs) (push) Has been skipped
Actions / Build Documentation (MkDocs) (pull_request) Has been skipped
Actions / Lint Code (Ruff & Pylint) (push) Failing after 44s
Actions / Lint Code (Ruff & Pylint) (pull_request) Failing after 44s

This commit is contained in:
cswimr 2025-01-25 22:11:37 +00:00
parent db125187c9
commit 850ddf15a6
Signed by: cswimr
GPG key ID: 0EC431A8DA8F8087

View file

@ -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.