@@ -10,18 +10,12 @@ class ID(ABC):
10
10
11
11
def __init__ (self , id_str : str ):
12
12
self .id_str = id_str
13
+ self .range_type = None
13
14
14
15
@staticmethod
15
16
@abstractmethod
16
17
def is_valid_id (id_str : str ) -> bool :
17
18
"""Determine whether the given string constitutes a valid ID."""
18
-
19
- raise NotImplementedError
20
-
21
- @property
22
- @abstractmethod
23
- def range_type () -> type :
24
- """Return the range ID type associated with the ID."""
25
19
26
20
raise NotImplementedError
27
21
@@ -41,6 +35,10 @@ def __hash__(self) -> int:
41
35
class TestID (ID ):
42
36
"""Represents a single test ID."""
43
37
38
+ def __init__ (self ):
39
+ super ().__init__ ()
40
+ self .range_type = TestRange
41
+
44
42
@classmethod
45
43
def is_valid_id (cls , id_str : str ) -> bool :
46
44
"""Determine whether the given string constitutes a valid test ID."""
@@ -92,14 +90,14 @@ def test_num(self) -> Optional[int]:
92
90
elif len (self .parts ) > 1 :
93
91
return int (self .parts [- 1 ])
94
92
95
- @property
96
- def range_type () -> type :
97
- return TestRange
98
-
99
93
100
94
class SeriesID (ID ):
101
95
"""Represents a single series ID."""
102
96
97
+ def __init__ (self ):
98
+ super ().__init__ ()
99
+ self .range_type = SeriesRange
100
+
103
101
@classmethod
104
102
def is_valid_id (cls , id_str : str ) -> bool :
105
103
"""Determine whether the given string constitutes a valid series ID."""
@@ -144,14 +142,10 @@ def as_int(self) -> int:
144
142
145
143
return int (self .id_str [1 :])
146
144
147
- @property
148
- def range_type () -> type :
149
- return SeriesRange
150
-
151
145
152
146
class GroupID :
153
147
"""Represents a single group ID."""
154
-
148
+
155
149
def __init__ (self , id_str : str ):
156
150
self .id_str = id_str
157
151
@@ -303,7 +297,7 @@ def resolve_ids(id_strs: List[str], id_type: ID, auto_last: bool = True) -> List
303
297
return [id_type ("last" )]
304
298
305
299
return ids
306
-
300
+
307
301
if "all" in id_strs :
308
302
return [id_type ("all" )]
309
303
@@ -339,7 +333,8 @@ def multi_convert(id_str: str) -> Union[List[TestID], List[SeriesID], List[Group
339
333
return [GroupID (id_str )]
340
334
341
335
342
- def resolve_mixed_ids (ids : Iterable [str ], auto_last : bool = True ) -> List [Union [TestID , SeriesID , GroupID ]]:
336
+ def resolve_mixed_ids (ids : Iterable [str ],
337
+ auto_last : bool = True ) -> List [Union [TestID , SeriesID , GroupID ]]:
343
338
"""Fully resolve all IDs in the given list into either test IDs, series IDs, or group IDs."""
344
339
345
340
ids = list (ids )
0 commit comments