Coverage for src/shephex/experiment/status.py: 82%
44 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-06-20 14:13 +0200
« prev ^ index » next coverage.py v7.6.1, created at 2025-06-20 14:13 +0200
3class Status(str):
5 valid = ["pending", "submitted", "running", "completed", "failed"]
7 def __init__(self, value: str) -> None:
8 if value not in self.valid:
9 raise ValueError(f"Invalid status: {value}")
10 self.value = value
12 @classmethod
13 def pending(cls) -> "Status":
14 return cls("pending")
16 @classmethod
17 def submitted(cls) -> "Status":
18 return cls("submitted")
20 @classmethod
21 def running(cls) -> "Status":
22 return cls("running")
24 @classmethod
25 def completed(cls) -> "Status":
26 return cls("completed")
28 @classmethod
29 def failed(cls) -> "Status":
30 return cls("failed")
32 def __eq__(self, other: "Status") -> bool:
33 if isinstance(other, str):
34 return self.value == other
35 return self.value == other.value
37class Pending(Status):
38 def __init__(self) -> None:
39 super().__init__("pending")
41class Submitted(Status):
42 def __init__(self) -> None:
43 super().__init__("submitted")
45class Running(Status):
46 def __init__(self) -> None:
47 super().__init__("running")
49class Completed(Status):
50 def __init__(self) -> None:
51 super().__init__("completed")
53class Failed(Status):
54 def __init__(self) -> None:
55 super().__init__("failed")
57if __name__ == '__main__':
59 status = Status.failed()
61 bools = "pending" in [Pending()]
62 print(bools)