From 361855377f51e63f7b8ca409a3b269eeb3a05987 Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Fri, 26 Jun 2026 17:02:53 -0700 Subject: [PATCH 1/3] feat(block-kit): add table block example Add a Bolt for Python Block Kit example for the table block, mirroring the official docs example. Imports TableBlock from slack_sdk and renders a header row plus two data rows with raw_text and rich_text link cells. Co-Authored-By: Claude --- block-kit/README.md | 1 + block-kit/src/blocks/table.py | 61 ++++++++++++++++++++++++++++ block-kit/tests/blocks/test_table.py | 58 ++++++++++++++++++++++++++ 3 files changed, 120 insertions(+) create mode 100644 block-kit/src/blocks/table.py create mode 100644 block-kit/tests/blocks/test_table.py diff --git a/block-kit/README.md b/block-kit/README.md index ee77ff0..dd26445 100644 --- a/block-kit/README.md +++ b/block-kit/README.md @@ -20,5 +20,6 @@ Read the [docs](https://docs.slack.dev/block-kit/) to learn concepts behind thes - **[Plan](https://docs.slack.dev/reference/block-kit/blocks/plan-block)**: Displays a collection of related tasks. [Implementation](./src/blocks/plan.py). - **[Rich text](https://docs.slack.dev/reference/block-kit/blocks/rich-text-block)**: Displays formatted, structured representation of text. [Implementation](./src/blocks/rich_text.py). - **[Section](https://docs.slack.dev/reference/block-kit/blocks/section-block)**: Displays text, possibly alongside elements. [Implementation](./src/blocks/section.py). +- **[Table](https://docs.slack.dev/reference/block-kit/blocks/table-block)**: Displays data arranged in rows and columns. [Implementation](./src/blocks/table.py). - **[Task card](https://docs.slack.dev/reference/block-kit/blocks/task-card-block)**: Displays a single task, representing a single action. [Implementation](./src/blocks/task_card.py). - **[Video](https://docs.slack.dev/reference/block-kit/blocks/video-block)**: Displays an embedded video player. [Implementation](./src/blocks/video.py). diff --git a/block-kit/src/blocks/table.py b/block-kit/src/blocks/table.py new file mode 100644 index 0000000..19155f0 --- /dev/null +++ b/block-kit/src/blocks/table.py @@ -0,0 +1,61 @@ +from slack_sdk.models.blocks import TableBlock + + +def example01() -> TableBlock: + """ + Displays data arranged in rows and columns. + https://docs.slack.dev/reference/block-kit/blocks/table-block/ + + A table with a header row and two data rows. The first column is wrapped + and contains raw text, while the second column is right-aligned and + contains rich text links. + """ + block = TableBlock( + column_settings=[ + {"is_wrapped": True}, + {"align": "right"}, + ], + rows=[ + [ + {"type": "raw_text", "text": "Header A"}, + {"type": "raw_text", "text": "Header B"}, + ], + [ + {"type": "raw_text", "text": "Data 1A"}, + { + "type": "rich_text", + "elements": [ + { + "type": "rich_text_section", + "elements": [ + { + "type": "link", + "text": "Data 1B", + "url": "https://slack.com", + } + ], + } + ], + }, + ], + [ + {"type": "raw_text", "text": "Data 2A"}, + { + "type": "rich_text", + "elements": [ + { + "type": "rich_text_section", + "elements": [ + { + "type": "link", + "text": "Data 2B", + "url": "https://slack.com", + } + ], + } + ], + }, + ], + ], + ) + return block diff --git a/block-kit/tests/blocks/test_table.py b/block-kit/tests/blocks/test_table.py new file mode 100644 index 0000000..f8eb942 --- /dev/null +++ b/block-kit/tests/blocks/test_table.py @@ -0,0 +1,58 @@ +import json + +from src.blocks import table + + +def test_example01(): + block = table.example01() + actual = block.to_dict() + expected = { + "type": "table", + "column_settings": [ + {"is_wrapped": True}, + {"align": "right"}, + ], + "rows": [ + [ + {"type": "raw_text", "text": "Header A"}, + {"type": "raw_text", "text": "Header B"}, + ], + [ + {"type": "raw_text", "text": "Data 1A"}, + { + "type": "rich_text", + "elements": [ + { + "type": "rich_text_section", + "elements": [ + { + "type": "link", + "text": "Data 1B", + "url": "https://slack.com", + } + ], + } + ], + }, + ], + [ + {"type": "raw_text", "text": "Data 2A"}, + { + "type": "rich_text", + "elements": [ + { + "type": "rich_text_section", + "elements": [ + { + "type": "link", + "text": "Data 2B", + "url": "https://slack.com", + } + ], + } + ], + }, + ], + ], + } + assert json.dumps(actual, sort_keys=True) == json.dumps(expected, sort_keys=True) From 76f91cebf869cb01a747631e58a1a2508dddad55 Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Tue, 4 Aug 2026 21:45:00 -0700 Subject: [PATCH 2/3] fix(table): match description to docs.slack.dev wording Co-Authored-By: Claude --- block-kit/src/blocks/table.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block-kit/src/blocks/table.py b/block-kit/src/blocks/table.py index 19155f0..2f834bc 100644 --- a/block-kit/src/blocks/table.py +++ b/block-kit/src/blocks/table.py @@ -3,7 +3,7 @@ def example01() -> TableBlock: """ - Displays data arranged in rows and columns. + Displays structured information in a table. https://docs.slack.dev/reference/block-kit/blocks/table-block/ A table with a header row and two data rows. The first column is wrapped From 5a9db7b1805447e9bcbbec1e718bec807b20c242 Mon Sep 17 00:00:00 2001 From: Eden Zimbelman Date: Tue, 4 Aug 2026 21:46:49 -0700 Subject: [PATCH 3/3] style(table): expand dict literals to one key per line Co-Authored-By: Claude --- block-kit/src/blocks/table.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/block-kit/src/blocks/table.py b/block-kit/src/blocks/table.py index 2f834bc..420b7b0 100644 --- a/block-kit/src/blocks/table.py +++ b/block-kit/src/blocks/table.py @@ -12,16 +12,29 @@ def example01() -> TableBlock: """ block = TableBlock( column_settings=[ - {"is_wrapped": True}, - {"align": "right"}, + { + "is_wrapped": True, + }, + { + "align": "right", + }, ], rows=[ [ - {"type": "raw_text", "text": "Header A"}, - {"type": "raw_text", "text": "Header B"}, + { + "type": "raw_text", + "text": "Header A", + }, + { + "type": "raw_text", + "text": "Header B", + }, ], [ - {"type": "raw_text", "text": "Data 1A"}, + { + "type": "raw_text", + "text": "Data 1A", + }, { "type": "rich_text", "elements": [ @@ -39,7 +52,10 @@ def example01() -> TableBlock: }, ], [ - {"type": "raw_text", "text": "Data 2A"}, + { + "type": "raw_text", + "text": "Data 2A", + }, { "type": "rich_text", "elements": [