Improve typing annotations

This commit is contained in:
Adam Goldsmith 2022-03-14 01:04:06 -04:00
parent c6503b91af
commit 16e3182d52
2 changed files with 10 additions and 10 deletions

View File

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

View File

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