@@ -10,15 +10,34 @@ class Color(BaseModel):
1010 g : int
1111 b : int
1212
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+
1323
1424class Font (BaseModel ):
1525 id : str
1626 name : str
1727 size : int
1828
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+
1938
2039class Mark (BaseModel ):
21- category : Literal ['bold' , 'italic' , 'textStyle' , 'link' ]
40+ category : Literal ['bold' , 'italic' , 'superscripted' , 'serifed' , 'monospaced' , ' textStyle' , 'link' ]
2241
2342 @model_validator (mode = 'before' )
2443 def check_details (self : Any ) -> Any :
@@ -37,11 +56,34 @@ def check_details(self: Any) -> Any:
3756 raise ValueError ('textStyle should not be provided when type is link' )
3857 return self
3958
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+
4065
4166class TextStyleMark (Mark ):
4267 color : Optional [Color ] = None
4368 font : Optional [Font ] = None
4469
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+
4579
4680class UrlMark (Mark ):
4781 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