|
14 | 14 | # You should have received a copy of the GNU General Public License |
15 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 |
|
17 | | -from typing import TYPE_CHECKING, Tuple |
| 17 | +from typing import ( |
| 18 | + TYPE_CHECKING, |
| 19 | + Optional, |
| 20 | + Tuple, |
| 21 | +) |
18 | 22 |
|
19 | 23 | from cylc.flow.cycling.loader import ( |
20 | 24 | get_interval, |
@@ -50,9 +54,16 @@ class TaskTrigger: |
50 | 54 | 'offset_is_irregular', 'offset_is_absolute', |
51 | 55 | 'offset_is_from_icp', 'initial_point'] |
52 | 56 |
|
53 | | - def __init__(self, task_name, cycle_point_offset, output, |
54 | | - offset_is_irregular=False, offset_is_absolute=False, |
55 | | - offset_is_from_icp=False, initial_point=None): |
| 57 | + def __init__( |
| 58 | + self, |
| 59 | + task_name: str, |
| 60 | + cycle_point_offset: str, |
| 61 | + output: str, |
| 62 | + offset_is_irregular: bool = False, |
| 63 | + offset_is_absolute: bool = False, |
| 64 | + offset_is_from_icp: bool = False, |
| 65 | + initial_point: 'Optional[PointBase]' = None, |
| 66 | + ): |
56 | 67 | self.task_name = task_name |
57 | 68 | self.cycle_point_offset = cycle_point_offset |
58 | 69 | self.output = output |
@@ -147,7 +158,24 @@ def __str__(self): |
147 | 158 | else: |
148 | 159 | return '%s:%s' % (self.task_name, self.output) |
149 | 160 |
|
150 | | - __repr__ = __str__ |
| 161 | + def __repr__(self) -> str: |
| 162 | + return f"<{type(self).__name__} {self}>" |
| 163 | + |
| 164 | + def __hash__(self) -> int: |
| 165 | + return hash(( |
| 166 | + self.task_name, |
| 167 | + self.cycle_point_offset, |
| 168 | + self.output, |
| 169 | + self.offset_is_irregular, |
| 170 | + self.offset_is_from_icp, |
| 171 | + self.offset_is_absolute, |
| 172 | + self.initial_point, |
| 173 | + )) |
| 174 | + |
| 175 | + def __eq__(self, other: object) -> bool: |
| 176 | + if not isinstance(other, TaskTrigger): |
| 177 | + return NotImplemented |
| 178 | + return hash(self) == hash(other) |
151 | 179 |
|
152 | 180 | @staticmethod |
153 | 181 | def standardise_name(name): |
|
0 commit comments