aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Manuel Ignacio Pérez Alcolea <[email protected]>2019-12-22 14:08:35 -0300
committerGravatar Manuel Ignacio Pérez Alcolea <[email protected]>2019-12-22 14:08:35 -0300
commitfcce6b5a7d56fddd0d015408257980b1bc56e4de (patch)
tree35a80c640617bcba68964582d2d2f19db98b3adb
parentMinor refactor moving `return ...` (diff)
Move type declarations for annotations and converters
It turns out how it was originally was the best idea. Now the `infractions` module imports `FetchedUser` and makes a `typing.Union` between it and `utils.UserTypes`. The usage of `FetchedUser` isn't needed in `utils` at all, and it shouldn't be used for/as type hinting there.
-rw-r--r--bot/cogs/moderation/infractions.py5
-rw-r--r--bot/cogs/moderation/utils.py6
2 files changed, 7 insertions, 4 deletions
diff --git a/bot/cogs/moderation/infractions.py b/bot/cogs/moderation/infractions.py
index 253a8db5b..5b6a63dbb 100644
--- a/bot/cogs/moderation/infractions.py
+++ b/bot/cogs/moderation/infractions.py
@@ -9,14 +9,17 @@ from discord.ext.commands import Context, command
from bot import constants
from bot.bot import Bot
from bot.constants import Event
+from bot.converters import FetchedUser
from bot.decorators import respect_role_hierarchy
from bot.utils.checks import with_role_check
from . import utils
from .scheduler import InfractionScheduler
-from .utils import MemberObject, UserTypes as MemberConverter
+from .utils import MemberObject, UserTypes
log = logging.getLogger(__name__)
+MemberConverter = t.Union[UserTypes, FetchedUser]
+
class Infractions(InfractionScheduler, commands.Cog):
"""Apply and pardon infractions on users for moderation purposes."""
diff --git a/bot/cogs/moderation/utils.py b/bot/cogs/moderation/utils.py
index d0eaba7c8..d564d0699 100644
--- a/bot/cogs/moderation/utils.py
+++ b/bot/cogs/moderation/utils.py
@@ -8,7 +8,7 @@ from discord.ext.commands import Context
from bot.api import ResponseCodeError
from bot.constants import Colours, Icons
-from bot.converters import Duration, FetchedUser, ISODateTime
+from bot.converters import Duration, ISODateTime
log = logging.getLogger(__name__)
@@ -24,13 +24,13 @@ INFRACTION_ICONS = {
RULES_URL = "https://pythondiscord.com/pages/rules"
APPEALABLE_INFRACTIONS = ("ban", "mute")
-UserTypes = t.Union[discord.Member, discord.User, FetchedUser]
+UserTypes = t.Union[discord.Member, discord.User]
MemberObject = t.Union[UserTypes, discord.Object]
Infraction = t.Dict[str, t.Union[str, int, bool]]
Expiry = t.Union[Duration, ISODateTime]
-async def post_user(ctx: Context, user: t.Union[discord.User, discord.Object]) -> t.Optional[dict]:
+async def post_user(ctx: Context, user: MemberObject) -> t.Optional[dict]:
"""
Create a new user in the database.