Skip to content

Commit

Permalink
Fix use of typing.cast(...)
Browse files Browse the repository at this point in the history
Gosh I'm an idiot
  • Loading branch information
Iapetus-11 committed May 30, 2024
1 parent e6f5368 commit ad39a81
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion bot/cogs/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, bot: VillagerBotCluster):

@property
def db(self) -> Database:
return typing.cast(self.bot.get_cog("Database"), Database)
return typing.cast(Database, self.bot.get_cog("Database"))

@commands.group(name="config", aliases=["settings", "conf", "gamerule"], case_insensitive=True)
async def config(self, ctx: Ctx):
Expand Down
6 changes: 3 additions & 3 deletions bot/cogs/commands/econ.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ def __init__(self, bot: VillagerBotCluster):

@property
def db(self) -> Database:
return typing.cast(self.bot.get_cog("Database"), Database)
return typing.cast(Database, self.bot.get_cog("Database"))

@property
def badges(self) -> Badges:
return typing.cast(self.bot.get_cog("Badges"), Badges)
return typing.cast(Badges, self.bot.get_cog("Badges"))

@property
def paginator(self) -> Paginator:
return typing.cast(self.bot.get_cog("Paginator"), Paginator)
return typing.cast(Paginator, self.bot.get_cog("Paginator"))

@functools.lru_cache(maxsize=None) # calculate chances for a specific pickaxe to find emeralds
def calc_yield_chance_list(self, pickaxe: str):
Expand Down
2 changes: 1 addition & 1 deletion bot/cogs/commands/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, bot: VillagerBotCluster):

@property
def db(self) -> Database:
return typing.cast(self.bot.get_cog("Database"), Database)
return typing.cast(Database, self.bot.get_cog("Database"))

@staticmethod
def lang_convert(msg, lang):
Expand Down
2 changes: 1 addition & 1 deletion bot/cogs/commands/minecraft.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, bot: VillagerBotCluster):

@property
def db(self) -> Database:
return typing.cast(self.bot.get_cog("Database"), Database)
return typing.cast(Database, self.bot.get_cog("Database"))

@commands.command(name="blockify", aliases=["mcpixelart", "mcart", "mcimage", "mcvideo"])
@commands.cooldown(1, 10, commands.BucketType.user)
Expand Down
2 changes: 1 addition & 1 deletion bot/cogs/commands/mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, bot: VillagerBotCluster):

@property
def db(self) -> Database:
return typing.cast(self.bot.get_cog("Database"), Database)
return typing.cast(Database, self.bot.get_cog("Database"))

def permission_check(self, ctx: Ctx, victim: discord.Member) -> bool:
author = ctx.author
Expand Down
4 changes: 2 additions & 2 deletions bot/cogs/commands/owner.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ async def cog_before_invoke(self, ctx: Ctx):

@property
def db(self) -> Database:
return typing.cast(self.bot.get_cog("Database"), Database)
return typing.cast(Database, self.bot.get_cog("Database"))

@property
def paginator(self) -> Paginator:
return typing.cast(self.bot.get_cog("Paginator"), Paginator)
return typing.cast(Paginator, self.bot.get_cog("Paginator"))

@commands.command(name="ownercommands", aliases=["ocmds", "ownerhelp", "ohelp", "ownercmds"])
@commands.is_owner()
Expand Down
4 changes: 2 additions & 2 deletions bot/cogs/commands/useful.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ def __init__(self, bot: VillagerBotCluster):

@property
def db(self) -> Database:
return typing.cast(self.bot.get_cog("Database"), Database)
return typing.cast(Database, self.bot.get_cog("Database"))

@property
def paginator(self) -> Paginator:
return typing.cast(self.bot.get_cog("Paginator"), Paginator)
return typing.cast(Paginator, self.bot.get_cog("Paginator"))

def cog_unload(self):
self.clear_snipes.cancel()
Expand Down
2 changes: 1 addition & 1 deletion bot/cogs/core/badges.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, bot: VillagerBotCluster):

@property
def db(self) -> Database:
return typing.cast(self.bot.get_cog("Database"), Database)
return typing.cast(Database, self.bot.get_cog("Database"))

async def fetch_user_badges(self, user_id) -> dict:
return dict(await self.db.fetch_user_badges(user_id))
Expand Down
2 changes: 1 addition & 1 deletion bot/cogs/core/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, bot: VillagerBotCluster):

@property
def badges(self) -> Badges:
return typing.cast(self.bot.get_cog("Badges"), "Badges")
return typing.cast("Badges", self.bot.get_cog("Badges"))

async def populate_caches(self):
# caches which need to be maintained across all clusters
Expand Down
4 changes: 2 additions & 2 deletions bot/cogs/core/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ def __init__(self, bot: VillagerBotCluster):

@property
def db(self) -> Database:
return typing.cast(self.bot.get_cog("Database"), Database)
return typing.cast(Database, self.bot.get_cog("Database"))

@property
def badges(self) -> Badges:
return typing.cast(self.bot.get_cog("Badges"), Badges)
return typing.cast(Badges, self.bot.get_cog("Badges"))

async def on_error(self, event, *args, **kwargs): # logs errors in events, such as on_message
self.bot.error_count += 1
Expand Down
2 changes: 1 addition & 1 deletion bot/cogs/core/mobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, bot: VillagerBotCluster):

@property
def db(self) -> Database:
return typing.cast(self.bot.get_cog("Database"), Database)
return typing.cast(Database, self.bot.get_cog("Database"))

def engage_check(self, ctx: Ctx):
def _engage_check(m: discord.Message):
Expand Down
2 changes: 1 addition & 1 deletion bot/cogs/core/voting.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, bot: VillagerBotCluster):

@property
def db(self) -> Database:
return typing.cast(self.bot.get_cog("Database"), Database)
return typing.cast(Database, self.bot.get_cog("Database"))

async def vote(self, *, user_id: int, site: str, is_weekend: bool, is_test: bool, json: str):
await self.bot.final_ready.wait()
Expand Down

0 comments on commit ad39a81

Please sign in to comment.