1+ from typing import Self
2+
13from pydantic import BaseModel , ConfigDict , Field , model_serializer
24
35from .day import Day
@@ -35,16 +37,16 @@ def value(self) -> int:
3537 def __abs__ (self ) -> "Duration" :
3638 return Duration (duration = abs (self .value ))
3739
38- def __lt__ (self , other : "Duration" ) -> bool :
40+ def __lt__ (self , other : Self ) -> bool :
3941 return self .value < other .value
4042
41- def __le__ (self , other : "Duration" ) -> bool :
43+ def __le__ (self , other : Self ) -> bool :
4244 return self .value <= other .value
4345
44- def __gt__ (self , other : "Duration" ) -> bool :
46+ def __gt__ (self , other : Self ) -> bool :
4547 return self .value > other .value
4648
47- def __ge__ (self , other : "Duration" ) -> bool :
49+ def __ge__ (self , other : Self ) -> bool :
4850 return self .value >= other .value
4951
5052 def __eq__ (self , other : object ) -> bool :
@@ -117,22 +119,22 @@ def value(self) -> int:
117119 def __add__ (self , dur : Duration ) -> "TimePoint" :
118120 return TimePoint (timepoint = (self .value + dur .value ))
119121
120- def __sub__ (self , other : "TimePoint" ) -> Duration :
122+ def __sub__ (self , other : Self ) -> Duration :
121123 return Duration (duration = (self .value - other .value ))
122124
123125 def __abs__ (self ) -> Duration :
124126 return Duration (duration = abs (self .value ))
125127
126- def __lt__ (self , other : "TimePoint" ) -> bool :
128+ def __lt__ (self , other : Self ) -> bool :
127129 return self .value < other .value
128130
129- def __le__ (self , other : "TimePoint" ) -> bool :
131+ def __le__ (self , other : Self ) -> bool :
130132 return self .value <= other .value
131133
132- def __gt__ (self , other : "TimePoint" ) -> bool :
134+ def __gt__ (self , other : Self ) -> bool :
133135 return self .value > other .value
134136
135- def __ge__ (self , other : "TimePoint" ) -> bool :
137+ def __ge__ (self , other : Self ) -> bool :
136138 return self .value >= other .value
137139
138140 def __eq__ (self , other : object ) -> bool :
@@ -198,11 +200,6 @@ class TimeSlot(BaseModel):
198200 Configuration for the model which allows extra fields and is not strict (@private)
199201 """
200202
201- id : int = Field (description = "The unique identifier for the time slot" )
202- """
203- The unique identifier for the time slot
204- """
205-
206203 times : list [TimeInstance ] = Field (description = "The list of time instances in the time slot" )
207204 """
208205 The list of time instances in the time slot
@@ -219,7 +216,10 @@ class TimeSlot(BaseModel):
219216 """
220217
221218 def __hash__ (self ) -> int :
222- return hash (self .id )
219+ """
220+ Hash the time slot by its string representation
221+ """
222+ return hash (str (self ))
223223
224224 def lab_time (self ) -> TimeInstance | None :
225225 """
0 commit comments