From 639dc9ac4c42a8c9ccd8e4736620c4521958fb40 Mon Sep 17 00:00:00 2001 From: Kazuhiro Sera Date: Thu, 23 Nov 2023 10:28:27 +0900 Subject: [PATCH] Add RichTextBlock to Block.parse() targets (#1433) --- slack_sdk/models/blocks/blocks.py | 2 ++ tests/slack_sdk/models/test_blocks.py | 1 + 2 files changed, 3 insertions(+) diff --git a/slack_sdk/models/blocks/blocks.py b/slack_sdk/models/blocks/blocks.py index 5bd0171d..5d672131 100644 --- a/slack_sdk/models/blocks/blocks.py +++ b/slack_sdk/models/blocks/blocks.py @@ -89,6 +89,8 @@ def parse(cls, block: Union[dict, "Block"]) -> Optional["Block"]: return HeaderBlock(**block) elif type == VideoBlock.type: return VideoBlock(**block) + elif type == RichTextBlock.type: + return RichTextBlock(**block) else: cls.logger.warning(f"Unknown block detected and skipped ({block})") return None diff --git a/tests/slack_sdk/models/test_blocks.py b/tests/slack_sdk/models/test_blocks.py index 4ea1158e..836f65b1 100644 --- a/tests/slack_sdk/models/test_blocks.py +++ b/tests/slack_sdk/models/test_blocks.py @@ -973,6 +973,7 @@ def test_complex(self): ], } self.assertDictEqual(dict_block, RichTextBlock(**dict_block).to_dict()) + self.assertDictEqual(dict_block, Block.parse(dict_block).to_dict()) _ = RichTextElementParts class_block = RichTextBlock(