diff options
author | 2019-08-16 10:38:04 +0200 | |
---|---|---|
committer | 2019-08-16 10:38:04 +0200 | |
commit | 64751a5895207b9511d07abef75084d4dda04a75 (patch) | |
tree | 0b665b946bfd5787003bec164ac50713423e419f | |
parent | Updating role sync tests for position and adding tests for deletion detection (diff) |
Adding missing function annotations
-rw-r--r-- | bot/cogs/sync/cog.py | 24 | ||||
-rw-r--r-- | bot/cogs/sync/syncers.py | 4 |
2 files changed, 14 insertions, 14 deletions
diff --git a/bot/cogs/sync/cog.py b/bot/cogs/sync/cog.py index 30b66c74e..999cb1e09 100644 --- a/bot/cogs/sync/cog.py +++ b/bot/cogs/sync/cog.py @@ -3,7 +3,7 @@ from typing import Callable, Iterable from discord import Guild, Member, Role from discord.ext import commands -from discord.ext.commands import Bot +from discord.ext.commands import Bot, Context from bot import constants from bot.api import ResponseCodeError @@ -26,10 +26,10 @@ class Sync: syncers.sync_users ) - def __init__(self, bot): + def __init__(self, bot: Bot) -> None: self.bot = bot - async def on_ready(self): + async def on_ready(self) -> None: """Syncs the roles/users of the guild with the database.""" guild = self.bot.get_guild(self.SYNC_SERVER_ID) if guild is not None: @@ -48,7 +48,7 @@ class Sync: syncer_name, total_created, total_updated, total_deleted ) - async def on_guild_role_create(self, role: Role): + async def on_guild_role_create(self, role: Role) -> None: """Adds newly create role to the database table over the API.""" await self.bot.api_client.post( 'bot/roles', @@ -61,11 +61,11 @@ class Sync: } ) - async def on_guild_role_delete(self, role: Role): + async def on_guild_role_delete(self, role: Role) -> None: """Deletes role from the database when it's deleted from the guild.""" await self.bot.api_client.delete('bot/roles/' + str(role.id)) - async def on_guild_role_update(self, before: Role, after: Role): + async def on_guild_role_update(self, before: Role, after: Role) -> None: """Syncs role with the database if any of the stored attributes were updated.""" if ( before.name != after.name @@ -84,7 +84,7 @@ class Sync: } ) - async def on_member_join(self, member: Member): + async def on_member_join(self, member: Member) -> None: """ Adds a new user or updates existing user to the database when a member joins the guild. @@ -119,7 +119,7 @@ class Sync: # If we got `404`, the user is new. Create them. await self.bot.api_client.post('bot/users', json=packed) - async def on_member_leave(self, member: Member): + async def on_member_leave(self, member: Member) -> None: """Updates the user information when a member leaves the guild.""" await self.bot.api_client.put( 'bot/users/' + str(member.id), @@ -133,7 +133,7 @@ class Sync: } ) - async def on_member_update(self, before: Member, after: Member): + async def on_member_update(self, before: Member, after: Member) -> None: """Updates the user information if any of relevant attributes have changed.""" if ( before.name != after.name @@ -164,12 +164,12 @@ class Sync: @commands.group(name='sync') @commands.has_permissions(administrator=True) - async def sync_group(self, ctx): + async def sync_group(self, ctx: Context) -> None: """Run synchronizations between the bot and site manually.""" @sync_group.command(name='roles') @commands.has_permissions(administrator=True) - async def sync_roles_command(self, ctx): + async def sync_roles_command(self, ctx: Context) -> None: """Manually synchronize the guild's roles with the roles on the site.""" initial_response = await ctx.send("📊 Synchronizing roles.") @@ -183,7 +183,7 @@ class Sync: @sync_group.command(name='users') @commands.has_permissions(administrator=True) - async def sync_users_command(self, ctx): + async def sync_users_command(self, ctx: Context) -> None: """Manually synchronize the guild's users with the users on the site.""" initial_response = await ctx.send("📊 Synchronizing users.") diff --git a/bot/cogs/sync/syncers.py b/bot/cogs/sync/syncers.py index 8f3f71440..23dd09d43 100644 --- a/bot/cogs/sync/syncers.py +++ b/bot/cogs/sync/syncers.py @@ -46,7 +46,7 @@ def get_roles_for_sync( return roles_to_create, roles_to_update, roles_to_delete -async def sync_roles(bot: Bot, guild: Guild): +async def sync_roles(bot: Bot, guild: Guild) -> Tuple[Set[Role], Set[Role], Set[Role]]: """ Synchronize roles found on the given `guild` with the ones on the API. @@ -164,7 +164,7 @@ def get_users_for_sync( return users_to_create, users_to_update -async def sync_users(bot: Bot, guild: Guild): +async def sync_users(bot: Bot, guild: Guild) -> Tuple[Set[Role], Set[Role], None]: """ Synchronize users found on the given `guild` with the ones on the API. |