Skip to content

feat(block-kit): add carousel block example - #97

Merged
zimeg merged 10 commits into
mainfrom
feat/block-kit-carousel-example
Sep 9, 2026
Merged

feat(block-kit): add carousel block example#97
zimeg merged 10 commits into
mainfrom
feat/block-kit-carousel-example

Conversation

@zimeg

@zimeg zimeg commented Jun 26, 2026

Copy link
Copy Markdown
Member

Summary

Adds a Python Block Kit example for the carousel block, mirroring the official docs example.

example01() builds a carousel of three cards, each with an icon, title, subtitle, hero image, body, and an action button — matching the reference JSON exactly.

  • block-kit/src/blocks/carousel.pyexample01() returning a CarouselBlock of CardBlocks
  • block-kit/tests/blocks/test_carousel.py — asserts the produced block deep-equals the expected payload
  • block-kit/README.md — adds the Carousel bullet (alphabetical) with docs + implementation links

Docs: https://docs.slack.dev/reference/block-kit/blocks/carousel-block

Validation

Run in block-kit/ against the pinned slack_sdk==3.42.0 / pytest==9.1.1 / ruff==0.15.20:

  • pytest -q — 33 passed (full suite, including new test_carousel.py)
  • ruff check src/blocks/carousel.py tests/blocks/test_carousel.py — all checks passed
  • ruff format --check ... — 2 files already formatted

Note: this is a sample app repo with no .changeset/, so no changeset was added.

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

🤖 Generated with Claude Code

zimeg and others added 3 commits June 26, 2026 16:58
Add a Python Block Kit example for the carousel block, mirroring the
official docs example: a carousel of three cards, each with an icon,
title, subtitle, hero image, body, and an action button.

Includes a test asserting the produced block matches the expected
payload, and a README bullet linking the reference and implementation.

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

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
CardBlock.icon and hero_image take Block Kit image element objects per the
card block reference (type/image_url/alt_text), but slack_sdk types them as
str | None, so ImageElement args trip mypy [arg-type]. Add
# type: ignore[arg-type] on each, matching the card example. (slack_sdk
typing bug — tracked separately.)

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@zimeg zimeg added enhancement New feature or request python Pull requests that update python code labels Aug 4, 2026
@zimeg zimeg self-assigned this Aug 4, 2026
Examples should not carry type-checker suppressions. Remove the
# type: ignore[arg-type] added for the ImageElement icon/hero_image args.
Until slackapi/python-slack-sdk#1937 lands (widening CardBlock.icon /
hero_image to accept an image element), mypy reports [arg-type] here by
design — the honest signal that slack_sdk mis-types these fields as str.

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

zimeg commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

⚠️ mypy is intentionally red on this PR (icon/hero_image [arg-type]).

The example builds icon/hero_image with ImageElement — the docs-correct image-element object (carries alt_text for accessibility). slack_sdk currently mis-types CardBlock.icon/hero_image as str | None, so mypy flags the object form. Rather than ship a # type: ignore in an example, the suppression was removed and the fix is upstream:

slackapi/python-slack-sdk#1937 widens those params to accept an image element.

Once #1937 lands and releases, this PR's mypy step goes green with no code change here. Tracking so it's not merged/forgotten in the red state.

zimeg and others added 4 commits August 4, 2026 16:28
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
…el-example

# Conflicts:
#	block-kit/README.md
…ple doc

- README: use the docs carousel-block description ("Displays related card
  blocks in a horizontally-scrolling container.") to match the docstring
  first line.
- carousel.py: simplify the specific-example line to "A sample carousel
  block." (docs description first line + URL kept per AGENTS.md).

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@zimeg
zimeg marked this pull request as ready for review September 9, 2026 17:06
@zimeg
zimeg requested a review from a team as a code owner September 9, 2026 17:06
zimeg and others added 2 commits September 9, 2026 10:08
Expand the inline title/subtitle text objects in the carousel test's
expected dict so each JSON field is on its own line, consistent with the
rest of the expected payload.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
The docs carousel example renders each card's title/subtitle/body mrkdwn
object with "verbatim": false. Set verbatim=False on every
MarkdownTextObject in the example and assert it in the test so the
payload matches docs.slack.dev. Each field is on its own line.

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

zimeg commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

📣 note: We now match the JSON examples shown in docs so I'll merge this.

@zimeg
zimeg merged commit cd7b4c3 into main Sep 9, 2026
7 checks passed
@zimeg
zimeg deleted the feat/block-kit-carousel-example branch September 9, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request python Pull requests that update python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant