From ca6a3ef0fade9a38231e3b55a87442ca2da42c95 Mon Sep 17 00:00:00 2001
From: Ernesto Rico Schmidt <ernesto@helsinki.at>
Date: Wed, 5 Apr 2023 17:09:38 -0400
Subject: [PATCH] Add type annotations

---
 program/services.py | 38 ++++++++++++++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/program/services.py b/program/services.py
index 1aeb018b..f11f64f4 100644
--- a/program/services.py
+++ b/program/services.py
@@ -43,12 +43,43 @@ class ScheduleData(TypedDict):
     default_playlist_id: int | None
     end_time: str
     first_date: str
+    id: int | None
     is_repetition: bool
     last_date: str | None
     rrule: int
+    show: int | None
     start_time: str
 
 
+class Collision(TypedDict):
+    end: str
+    id: int
+    memo: str
+    note_id: int | None
+    playlist_id: int | None
+    schedule: int
+    show: int
+    show_name: str
+    start: str
+
+
+class ProjectedEntry(TypedDict):
+    collisions: list[Collision]
+    end: str
+    error: str | None
+    hash: str
+    solution_choices: set
+    start: str
+
+
+class ConflictsData(TypedDict):
+    projected: list[ProjectedEntry]
+    solutions: dict[str, str]
+    notes: dict
+    playlists: dict
+    schedule: ScheduleData
+
+
 # TODO: add type annotations
 def resolve_conflicts(data, schedule_pk, show_pk):
     """
@@ -380,8 +411,7 @@ def instantiate_upcoming_schedule(
     )
 
 
-# TODO: add type annotations
-def make_conflicts(sdl, schedule_pk, show_pk):
+def make_conflicts(data: ScheduleData, schedule_pk: int | None, show_pk: int):
     """
     Retrieves POST vars
     Generates a schedule
@@ -390,7 +420,7 @@ def make_conflicts(sdl, schedule_pk, show_pk):
     """
 
     # Generate schedule to be saved
-    schedule = instantiate_upcoming_schedule(sdl, show_pk, schedule_pk)
+    schedule = instantiate_upcoming_schedule(data, show_pk, schedule_pk)
 
     # Copy if first_date changes for generating timeslots
     gen_schedule = schedule
@@ -399,7 +429,7 @@ def make_conflicts(sdl, schedule_pk, show_pk):
 
     # If extending: Get last timeslot and start generating from that date on
     if schedule_pk is not None:
-        existing_schedule = Schedule.objects.get(pk=int(schedule_pk))
+        existing_schedule = Schedule.objects.get(pk=schedule_pk)
 
         if schedule.last_date > existing_schedule.last_date:
             last_timeslot = (
-- 
GitLab