@@ -10,15 +10,34 @@ class Color(BaseModel):
10
10
g : int
11
11
b : int
12
12
13
+ def __eq__ (self , other : Any ) -> bool :
14
+ return (isinstance (other , Color ) and
15
+ self .id == other .id and
16
+ self .r == other .r and
17
+ self .g == other .g and
18
+ self .b == other .b )
19
+
20
+ def __hash__ (self ) -> int :
21
+ return hash ((self .id , self .r , self .g , self .b ))
22
+
13
23
14
24
class Font (BaseModel ):
15
25
id : str
16
26
name : str
17
27
size : int
18
28
29
+ def __eq__ (self , other : Any ) -> bool :
30
+ return (isinstance (other , Font ) and
31
+ self .id == other .id and
32
+ self .size == other .size and
33
+ self .name == other .name )
34
+
35
+ def __hash__ (self ) -> int :
36
+ return hash ((self .id , self .size , self .name ))
37
+
19
38
20
39
class Mark (BaseModel ):
21
- category : Literal ['bold' , 'italic' , 'textStyle' , 'link' ]
40
+ category : Literal ['bold' , 'italic' , 'superscripted' , 'serifed' , 'monospaced' , ' textStyle' , 'link' ]
22
41
23
42
@model_validator (mode = 'before' )
24
43
def check_details (self : Any ) -> Any :
@@ -37,11 +56,34 @@ def check_details(self: Any) -> Any:
37
56
raise ValueError ('textStyle should not be provided when type is link' )
38
57
return self
39
58
59
+ def __eq__ (self , other ):
60
+ return isinstance (other , Mark ) and self .category == other .category
61
+
62
+ def __hash__ (self ) -> int :
63
+ return hash (self .category )
64
+
40
65
41
66
class TextStyleMark (Mark ):
42
67
color : Optional [Color ] = None
43
68
font : Optional [Font ] = None
44
69
70
+ def __eq__ (self , other ):
71
+ return (isinstance (other , TextStyleMark ) and
72
+ self .category == other .category and
73
+ self .color == other .color and
74
+ self .font == other .font )
75
+
76
+ def __hash__ (self ) -> int :
77
+ return hash ((self .category , self .color , self .font ))
78
+
45
79
46
80
class UrlMark (Mark ):
47
81
url : str
82
+
83
+ def __eq__ (self , other ):
84
+ return (isinstance (other , UrlMark ) and
85
+ self .category == other .category and
86
+ self .url == other .url )
87
+
88
+ def __hash__ (self ) -> int :
89
+ return hash ((self .category , self .url ))
0 commit comments