22
33from dataclasses import dataclass
44from datetime import datetime
5- from enum import Enum , auto
6- from functools import cached_property
5+ from enum import Enum
76from typing import Any , Awaitable , Callable , List , Self , cast , overload
87
98from discord import Color
1211
1312
1413class IssueState (Enum ):
15- OPEN = auto ()
16- CLOSED = auto ()
17- NOT_PLANNED = auto ()
14+ OPEN = Color .from_rgb (63 , 185 , 80 )
15+ CLOSED = Color .from_rgb (171 , 125 , 248 )
16+ NOT_PLANNED = Color .from_rgb (145 , 152 , 161 )
17+
18+ def __init__ (self , color : Color ):
19+ self .color = color
1820
1921 @classmethod
2022 def of (cls , issue : Issue ) -> IssueState :
@@ -26,22 +28,15 @@ def of(cls, issue: Issue) -> IssueState:
2628 case _:
2729 return IssueState .CLOSED
2830
29- @cached_property
30- def color (self ):
31- match self :
32- case IssueState .OPEN :
33- return Color .from_rgb (63 , 185 , 80 )
34- case IssueState .CLOSED :
35- return Color .from_rgb (171 , 125 , 248 )
36- case IssueState .NOT_PLANNED :
37- return Color .from_rgb (145 , 152 , 161 )
38-
3931
4032class PullRequestState (Enum ):
41- OPEN = auto ()
42- DRAFT = auto ()
43- MERGED = auto ()
44- CLOSED = auto ()
33+ OPEN = Color .from_rgb (63 , 185 , 80 )
34+ DRAFT = Color .from_rgb (145 , 152 , 161 )
35+ MERGED = Color .from_rgb (171 , 125 , 248 )
36+ CLOSED = Color .from_rgb (248 , 81 , 73 )
37+
38+ def __init__ (self , color : Color ):
39+ self .color = color
4540
4641 @overload
4742 @classmethod
@@ -78,36 +73,15 @@ def of(cls, pr: Issue | PullRequest) -> PullRequestState | None:
7873 case _:
7974 return PullRequestState .CLOSED
8075
81- @cached_property
82- def color (self ):
83- match self :
84- case PullRequestState .OPEN :
85- return Color .from_rgb (63 , 185 , 80 )
86- case PullRequestState .DRAFT :
87- return Color .from_rgb (145 , 152 , 161 )
88- case PullRequestState .MERGED :
89- return Color .from_rgb (171 , 125 , 248 )
90- case PullRequestState .CLOSED :
91- return Color .from_rgb (248 , 81 , 73 )
92-
9376
9477class CommitCheckState (Enum ):
95- SUCCESS = auto ()
96- FAILURE = auto ()
97- PENDING = auto ()
98- NEUTRAL = auto ()
99-
100- @cached_property
101- def color (self ):
102- match self :
103- case CommitCheckState .SUCCESS :
104- return Color .from_rgb (35 , 134 , 54 )
105- case CommitCheckState .FAILURE :
106- return Color .from_rgb (218 , 54 , 51 )
107- case CommitCheckState .PENDING :
108- return Color .from_rgb (158 , 106 , 3 )
109- case CommitCheckState .NEUTRAL :
110- return None
78+ SUCCESS = Color .from_rgb (35 , 134 , 54 )
79+ FAILURE = Color .from_rgb (218 , 54 , 51 )
80+ PENDING = Color .from_rgb (158 , 106 , 3 )
81+ NEUTRAL = None
82+
83+ def __init__ (self , color : Color | None ):
84+ self .color = color
11185
11286
11387@dataclass
0 commit comments