Skip to content

feat(models): add data_table Block Kit block - #1900

Open
zimeg wants to merge 10 commits into
mainfrom
chore/block-kit-data-table-wt
Open

zimeg wants to merge 10 commits into
mainfrom
chore/block-kit-data-table-wt

Conversation

@zimeg

@zimeg zimeg commented Jun 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds the net-new data_table Block Kit block to the SDK models. The block displays structured, paginated data in a table with a required caption.

  • DataTableBlock with rows (required), caption (required), page_size, row_header_column_index, and block_id
  • Registered the data_table type in Block.parse
  • Exported DataTableBlock from slack_sdk.models.blocks
  • Validators for required rows/caption and page_size range (1-100)
  • ActionCellObject for action_cell cells (a required button element and an optional raw_text/raw_number fallback), parsed in DataTableBlock rows only since action cells aren't allowed in table, and exported from slack_sdk.models.blocks
  • Merged main to resolve conflicts with AuthProviderBlock and the already-merged RawNumberObject (feat(models): allow raw_number cells in TableBlock rows #1964), keeping main's versions
  • Tests mirroring the existing TableBlock tests (basic doc example, all fields, rich_text cells, empty-rows validation, required caption, page_size range), plus action_cell round-trips with and without fallback and element/fallback validation

Cell types raw_text / raw_number / rich_text are passed through as given, matching the existing TableBlock convention in this repo. action_cell dicts are parsed into ActionCellObject so the button element is validated.

Reference

https://docs.slack.dev/reference/block-kit/blocks/data-table-block

Validation

Run in a fresh venv (./scripts/install.sh, Python 3.14):

  • ./scripts/run_tests.sh tests/slack_sdk/models/test_blocks.py -> 133 passed
  • ./scripts/lint.sh -> clean
  • ./scripts/run_mypy.sh -> no issues
  • Full pytest tests/ -> passing (one unrelated rate-limit retry test flaked once and passed on rerun)

One block per PR; data_visualization is intentionally not included here.

Add the net-new `data_table` block to the Block Kit models. The block
displays structured, paginated data with a required caption.

- DataTableBlock with rows (required), caption (required), page_size,
  row_header_column_index, and block_id
- register the type in Block.parse and export it from
  slack_sdk.models.blocks
- validators for required rows/caption and page_size range (1-100)
- tests mirroring the existing TableBlock tests

Ref: https://docs.slack.dev/reference/block-kit/blocks/data-table-block

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@codecov

codecov Bot commented Jun 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.38462% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.40%. Comparing base (d9618f8) to head (6311b50).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
slack_sdk/models/blocks/basic_components.py 91.42% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1900      +/-   ##
==========================================
+ Coverage   84.38%   84.40%   +0.02%     
==========================================
  Files         118      118              
  Lines       13812    13876      +64     
==========================================
+ Hits        11655    11712      +57     
- Misses       2157     2164       +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

zimeg and others added 4 commits September 8, 2026 17:04
…ects

Mirrors node-slack-sdk#2638: data_table rows accept raw_text, raw_number,
and rich_text cells. Adds RawNumberObject (value + display text, min-length-1)
and widens DataTableBlock.rows to Union[RawTextObject, RawNumberObject,
RichTextBlock, Dict]. Field wording tracks the docs/node model verbatim.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
raw_number has no dedicated composition-object reference page (it is only
documented inline on the data-table-block page). Match node-slack-sdk#2638's
RawNumberElement, which deliberately carries no @see link for the same reason.
The DataTableBlock docstring keeps the URL — that page is the block's own home.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Match the recently-added sibling blocks (AlertBlock, CardBlock, ContainerBlock,
CarouselBlock), which all use the one-line block_id description. DataTableBlock
had inherited the legacy verbose 5-line variant.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@zimeg zimeg added enhancement M-T: A feature request for new functionality semver:minor models labels Sep 9, 2026
@zimeg zimeg self-assigned this Sep 9, 2026
zimeg and others added 3 commits September 8, 2026 17:32
The docs data-table-block Fields table (and node-slack-sdk#2638) describe rows
as exactly 'An array consisting of table rows.' — drop the extra cell-type
sentence that was appended, per the verbatim-docs-field convention.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Matches both alphabetical order (Number < Text) and node-slack-sdk#2638's
composition-objects order (RawNumberElement before RawTextElement). No behavior
change — RawNumberObject extends JsonObject, so it has no dependency on the
sibling class.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Match the class order in the source files:
- RawNumberObjectTests before RawTextObjectTests (Number before Text, as in
  basic_components.py and node-slack-sdk#2638).
- DataTableBlockTests moved to the end, after CarouselBlockTests, mirroring
  DataTableBlock's position at the end of blocks.py.
Pre-existing test ordering left untouched (out of scope for this PR).

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>

@zimeg zimeg left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 A few notes for the amazing readers and kind reviewers.

CarouselBlock(elements=[]).validate_json()


class DataTableBlockTests(unittest.TestCase):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📇 note: These tests follow CarouselBlock and holds off on wider orderings for now.

Comment on lines +1363 to +1365
# ----------------------------------------------
# RawNumberObject
# ----------------------------------------------

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎲 note: This and the RawTextObject following might later be moved to tests for composition objects perhaps?

@zimeg
zimeg marked this pull request as ready for review September 9, 2026 02:58
@zimeg
zimeg requested a review from a team as a code owner September 9, 2026 02:58
@zimeg zimeg added this to the 3.next milestone Sep 9, 2026
@zimeg zimeg modified the milestones: 3.45.0, 3.next Oct 1, 2026
@zimeg zimeg modified the milestones: 3.46.0, 3.47.0 Oct 30, 2026
zimeg added 2 commits November 5, 2026 15:50
# Conflicts:
#	slack_sdk/models/blocks/blocks.py
#	tests/slack_sdk/models/test_blocks.py

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement M-T: A feature request for new functionality models semver:minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant