From 16e3182d5251d6838816c5b6f1b144b75c51ef2c Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Mon, 14 Mar 2022 01:04:06 -0400 Subject: [PATCH] Improve typing annotations --- ahtcg_bot.py | 16 ++++++++-------- arkhamdb.py | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ahtcg_bot.py b/ahtcg_bot.py index c07ba6a..03dbff1 100755 --- a/ahtcg_bot.py +++ b/ahtcg_bot.py @@ -15,7 +15,7 @@ class ArkhamDBUpdater(commands.Bot): channel_list: set[int] arkhamdb_client: ArkhamDBClient - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: super().__init__(*args, **kwargs) # TODO: should really be a database @@ -29,9 +29,9 @@ class ArkhamDBUpdater(commands.Bot): await self.arkhamdb_client.close() await super().close() - def setup_commands(self): + def setup_commands(self) -> None: @self.command(name='monitor') - async def monitor(ctx: commands.Context): + async def monitor(ctx: commands.Context) -> None: """Watch this channel for deck links and link to latest versions.""" await ctx.message.reply('Now monitoring this channel for deck IDs', mention_author=True) self.channel_list.add(ctx.message.channel.id) @@ -39,14 +39,14 @@ class ArkhamDBUpdater(commands.Bot): json.dump(list(self.channel_list), f) @self.command(name='forget') - async def forget(ctx: commands.Context): + async def forget(ctx: commands.Context) -> None: """Remove this channel from the monitor list""" await ctx.message.reply('No longer monitoring this channel for deck IDs', mention_author=True) self.channel_list.discard(ctx.message.channel.id) with open('channel_list.json', 'w') as f: json.dump(list(self.channel_list), f) - async def on_ready(self): + async def on_ready(self) -> None: print(f'Logged in as {self.user} (ID: {self.user.id})') print('Enabled on servers:') async for guild in self.fetch_guilds(limit=150): @@ -118,14 +118,14 @@ class ArkhamDBUpdater(commands.Bot): message.channel.id in self.channel_list: await self.update_channel_latest_decks(message.channel) - async def on_message(self, message: discord.Message): + async def on_message(self, message: discord.Message) -> None: await self.process_commands(message) await self.maybe_update_channel_for_message(message) - async def on_message_edit(self, before: discord.Message, after: discord.Message): + async def on_message_edit(self, before: discord.Message, after: discord.Message) -> None: await self.maybe_update_channel_for_message(after) - async def on_message_delete(self, message: discord.Message): + async def on_message_delete(self, message: discord.Message) -> None: await self.maybe_update_channel_for_message(message) @tasks.loop(hours=1) diff --git a/arkhamdb.py b/arkhamdb.py index ca81063..1f19a0f 100644 --- a/arkhamdb.py +++ b/arkhamdb.py @@ -34,11 +34,11 @@ class ArkhamDBClient: origin: str - def __init__(self, arkhamdb_origin: str = ARKHAMDB_ORIGIN): + def __init__(self, arkhamdb_origin: str = ARKHAMDB_ORIGIN) -> None: self._session = aiohttp.ClientSession() self.origin = arkhamdb_origin - async def close(self): + async def close(self) -> None: await self._session.close() async def get_latest_deck(self, deck_id: int) -> ArkhamDBDeck: