(cls, data: Dict[str, Any])
| 123 | |
| 124 | @classmethod |
| 125 | def from_dict(cls, data: Dict[str, Any]) -> "MessageBlock": |
| 126 | raw_type = data.get("type") or MessageBlockType.TEXT.value |
| 127 | try: |
| 128 | block_type = MessageBlockType(raw_type) |
| 129 | except ValueError: |
| 130 | block_type = MessageBlockType.DATA |
| 131 | attachment_data = data.get("attachment") |
| 132 | attachment = None |
| 133 | if isinstance(attachment_data, dict): |
| 134 | attachment = AttachmentRef.from_dict(attachment_data) |
| 135 | return cls( |
| 136 | type=block_type, |
| 137 | text=data.get("text"), |
| 138 | attachment=attachment, |
| 139 | data=data.get("data") or {}, |
| 140 | ) |
| 141 | |
| 142 | @classmethod |
| 143 | def text_block(cls, text: str) -> "MessageBlock": |
nothing calls this directly
no test coverage detected