Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial_value for RichTextInputElement should also accept type RichTextBlock #1571

Closed
1 of 9 tasks
macintacos opened this issue Oct 9, 2024 · 0 comments · Fixed by #1572
Closed
1 of 9 tasks

initial_value for RichTextInputElement should also accept type RichTextBlock #1571

macintacos opened this issue Oct 9, 2024 · 0 comments · Fixed by #1572
Assignees
Labels
bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented Version: 3x web-client
Milestone

Comments

@macintacos
Copy link

While using the RichTextInputElement, I realized through the type information that the type of initial_value expects to be an optional dictionary. There is seemingly no mention of RichTextBlock, so I had thought that at that point I would need to go and look at the API and manually create dictionaries to handle this.

This is not true. initial_value can be set to a RichTextBlock directly, without even needing to convert it to a dictionary. For example, this code works, without me even needing to transform any of these blocks to a dict:

blocks.InputBlock(
    label="Description / Context",
    block_id="description",
    element=blocks.RichTextInputElement(
        action_id="contents",
        initial_value=blocks.RichTextBlock(
            elements=[
                blocks.RichTextSectionElement(
                    elements=[
                        blocks.RichTextElementParts.Text(text="Hey, "),
                        blocks.RichTextElementParts.Text(
                            text="this", style={"italic": True}
                        ),
                        blocks.RichTextElementParts.Text(
                            text="is what you should be looking at. "
                        ),
                        blocks.RichTextElementParts.Text(
                            text="Please", style={"bold": True}
                        ),
                    ]
                )
            ],
        ),
    ),
)

...but it gives me an error in my IDE from mypy (rightly, because initial_value doesn't have RichTextBlock in its type definition):

CleanShot 2024-10-09 at 17 08 26@2x

Can the initial_value for RichTextInputElement include RichTextBlock? Thanks!

Category (place an x in each of the [ ])

  • slack_sdk.web.WebClient (sync/async) (Web API client)
  • slack_sdk.webhook.WebhookClient (sync/async) (Incoming Webhook, response_url sender)
  • slack_sdk.models (UI component builders)
  • slack_sdk.oauth (OAuth Flow Utilities)
  • slack_sdk.socket_mode (Socket Mode client)
  • slack_sdk.audit_logs (Audit Logs API client)
  • slack_sdk.scim (SCIM API client)
  • slack_sdk.rtm (RTM client)
  • slack_sdk.signature (Request Signature Verifier)

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

@seratch seratch added bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented web-client Version: 3x and removed untriaged labels Oct 9, 2024
@seratch seratch added this to the 3.33.2 milestone Oct 9, 2024
@seratch seratch self-assigned this Oct 9, 2024
@seratch seratch closed this as completed Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented Version: 3x web-client
Projects
None yet
2 participants