Modernized codebase with NamedTuples, StrEnum, override decorators, slots, and other idiomatic improvements.
CI / Formatting (push) Successful in 4s
CI / Linting (push) Successful in 5s
CI / Tests (push) Successful in 21s
CI / Type Checking (push) Successful in 10s
CI / Spelling (push) Successful in 5s

This commit is contained in:
2026-03-22 20:02:31 -04:00
parent a23d252f27
commit 23cc721612
12 changed files with 155 additions and 91 deletions
+5 -5
View File
@@ -27,7 +27,7 @@ if TYPE_CHECKING:
from crabstero.database import Database
class Flag(enum.Enum):
class Flag(enum.StrEnum):
"""Enum of all supported flag names."""
NO_REPLY = "noReply"
@@ -35,7 +35,7 @@ class Flag(enum.Enum):
ALLOW_PINGS = "allowPings"
class EntityType(enum.Enum):
class EntityType(enum.StrEnum):
"""Enum of entity types that can have flags."""
CHANNEL = "channel"
@@ -65,7 +65,7 @@ async def set_flag(
:param entity_type: The type of the entity.
:param flag: The flag to set.
"""
await db.set_flag(entity_type.value, _entity_id(entity), flag.value)
await db.set_flag(entity_type, _entity_id(entity), flag)
async def clear_flag(
@@ -81,7 +81,7 @@ async def clear_flag(
:param entity_type: The type of the entity.
:param flag: The flag to clear.
"""
await db.clear_flag(entity_type.value, _entity_id(entity), flag.value)
await db.clear_flag(entity_type, _entity_id(entity), flag)
async def is_flag_set(
@@ -98,4 +98,4 @@ async def is_flag_set(
:param flag: The flag to check for.
:return: True if the flag is set, False otherwise.
"""
return await db.is_flag_set(entity_type.value, _entity_id(entity), flag.value)
return await db.is_flag_set(entity_type, _entity_id(entity), flag)