22from typing import List , Optional , Union
33
44from pydantic import BaseModel
5+ from typing_extensions import Literal
56
67
78class Icon (Enum ):
@@ -25,6 +26,7 @@ class TextStyle(Enum):
2526
2627
2728class BaseBlock (BaseModel ):
29+ type : str
2830 pass
2931
3032
@@ -33,35 +35,41 @@ class BaseInlineTextBlock(BaseBlock):
3335
3436
3537class TextBlock (BaseInlineTextBlock ):
38+ type : Literal ["text" ] = "text"
3639 text : str
3740 style : Optional [TextStyle ] = None
3841
3942
4043class LinkBlock (BaseInlineTextBlock ):
44+ type : Literal ["link" ] = "link"
4145 text : str
4246 url : str
4347
4448
4549class IconBlock (BaseInlineTextBlock ):
50+ type : Literal ["icon" ] = "icon"
4651 icon : Icon
4752
4853
4954InlineBlock = Union [TextBlock , LinkBlock , IconBlock ]
5055
5156
5257class HeaderBlock (BaseBlock ):
58+ type : Literal ["header" ] = "header"
5359 text : str
5460
5561
5662class CodeBlock (BaseBlock ):
63+ type : Literal ["code" ] = "code"
5764 text : str
5865
5966
6067class DividerBlock (BaseBlock ):
61- pass
68+ type : Literal [ "divider" ] = "divider"
6269
6370
6471class LineBlock (BaseBlock ):
72+ type : Literal ["line" ] = "line"
6573 inlines : List [InlineBlock ]
6674 sep : str = " "
6775
@@ -71,19 +79,22 @@ class BaseLinesBlock(BaseBlock):
7179
7280
7381class LinesBlock (BaseLinesBlock ):
74- pass
82+ type : Literal [ "lines" ] = "lines"
7583
7684
7785class FactBlock (BaseBlock ):
86+ type : Literal ["fact" ] = "fact"
7887 title : LineBlock
7988 value : LineBlock
8089
8190
8291class FactListBlock (BaseBlock ):
92+ type : Literal ["fact_list" ] = "fact_list"
8393 facts : List [FactBlock ]
8494
8595
8696class ExpandableBlock (BaseBlock ):
97+ type : Literal ["expandable" ] = "expandable"
8798 title : str
8899 body : List ["InExpandableBlock" ]
89100 expanded : bool = False
@@ -98,4 +109,5 @@ class ExpandableBlock(BaseBlock):
98109 "ExpandableBlock" ,
99110]
100111
101- ExpandableBlock .model_rebuild ()
112+ # Update forward references for recursive types
113+ ExpandableBlock .update_forward_refs ()
0 commit comments