From 1be5731cdadb78f386000270c671677693e8ef1c Mon Sep 17 00:00:00 2001 From: rina Date: Tue, 3 Dec 2024 20:24:54 +1000 Subject: [PATCH] fix types oopsie lists aren't hashable, obviously. --- uqcsbot/advent.py | 2 +- uqcsbot/utils/advent_utils.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/uqcsbot/advent.py b/uqcsbot/advent.py index fa0a49f..30658f8 100644 --- a/uqcsbot/advent.py +++ b/uqcsbot/advent.py @@ -212,7 +212,7 @@ def make_message_arguments(self) -> Dict[str, Any]: ) leaderboard = self._build_leaderboard(self._visible_members) - scoreboard_image = render_leaderboard_to_image(leaderboard) + scoreboard_image = render_leaderboard_to_image(tuple(leaderboard)) file = discord.File(io.BytesIO(scoreboard_image), self.basename + ".png") embed.set_image(url=f"attachment://{file.filename}") diff --git a/uqcsbot/utils/advent_utils.py b/uqcsbot/utils/advent_utils.py index c8aea07..0ddcfbe 100644 --- a/uqcsbot/utils/advent_utils.py +++ b/uqcsbot/utils/advent_utils.py @@ -1,6 +1,7 @@ from typing import ( Any, DefaultDict, + Iterable, List, Literal, Dict, @@ -418,7 +419,7 @@ def render_leaderboard_to_text(leaderboard: Leaderboard) -> str: def _isolate_leaderboard_layers( - leaderboard: Leaderboard, + leaderboard: Iterable[str | ColourFragment], ) -> Tuple[str, Dict[Colour, str]]: """ Given a leaderboard made up of coloured fragments, split the @@ -448,7 +449,7 @@ def _isolate_leaderboard_layers( @lru_cache(maxsize=16) -def render_leaderboard_to_image(leaderboard: Leaderboard) -> bytes: +def render_leaderboard_to_image(leaderboard: Tuple[str | ColourFragment, ...]) -> bytes: spaces, layers = _isolate_leaderboard_layers(leaderboard) # NOTE: font choice should support as wide a range of glyphs as possible, @@ -477,7 +478,7 @@ def render_leaderboard_to_image(leaderboard: Leaderboard) -> bytes: def build_leaderboard( - columns: List[LeaderboardColumn], members: List[Member], day: Optional[Day] + columns: List[LeaderboardColumn], members: Iterable[Member], day: Optional[Day] ): """ Returns a leaderboard made up of fragments, with the given column configuration