From ce7ba4285a9bbceef857702ed64ce07f625b0569 Mon Sep 17 00:00:00 2001 From: stijndcl Date: Sun, 25 Sep 2022 15:58:36 +0200 Subject: [PATCH] Put slots in set at the end --- didier/data/embeds/schedules.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/didier/data/embeds/schedules.py b/didier/data/embeds/schedules.py index 16095d2..ef829cf 100644 --- a/didier/data/embeds/schedules.py +++ b/didier/data/embeds/schedules.py @@ -222,7 +222,7 @@ async def parse_schedule_from_content(content: str, *, database_session: AsyncSe calendar = Calendar(content) events = list(calendar.events) course_codes: dict[str, UforaCourse] = {} - slots: set[ScheduleSlot] = set() + slots: list[ScheduleSlot] = [] for event in events: code = parse_course_code(event.name) @@ -248,9 +248,10 @@ async def parse_schedule_from_content(content: str, *, database_session: AsyncSe if any(s.could_merge_with(slot) for s in slots): continue - slots.add(slot) + slots.append(slot) - return Schedule(slots=slots) + # Cast to set at the END because the __hash__ can change while merging with others + return Schedule(slots=set(slots)) async def parse_schedule(name: ScheduleType, *, database_session: AsyncSession) -> Optional[Schedule]: