Skip to content

text type hint in LinkButtonElement does not accept PlainTextObject/dict #1178

@noqcks

Description

@noqcks

Reproducible in:

The following code results in a type checking error (using mypy for type checking)

 LinkButtonElement(
    text=PlainTextObject(
        text="text    
    ),
    url="http://slack.com",
)
main.py:551: error: Argument "text" to "LinkButtonElement" has incompatible type "PlainTextObject"; expected "str"

From what I understand, a PlainTextObject is appropriate for this element? https://api.slack.com/reference/block-kit/block-elements#button__examples

Could you please confirm whether 1 & 2 below are both valid
1.

 LinkButtonElement(
    text=PlainTextObject(
        text="text    
    ),
    url="http://slack.com",
)
 LinkButtonElement(
    text="text"
    url="http://slack.com",
)

The Slack SDK version

slack-sdk==3.14.1

Python runtime version

Python 3.9.6

OS info

ProductName:	macOS
ProductVersion:	12.2
BuildVersion:	21D49
Darwin Kernel Version 21.3.0: Wed Jan  5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_X86_64

Steps to reproduce:

  1. Create a LinkButtonBlock with a PlainTextObject element
  2. run mypy on your code

Expected result:

I expect to see no error from mypy

Actual result:

main.py:551: error: Argument "text" to "LinkButtonElement" has incompatible type "PlainTextObject"; expected "str"

Requirements

For general questions/issues about Slack API platform or its server-side, could you submit questions at https://my.slack.com/help/requests/new instead. 🙇

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Version: 3xbugM-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documentedweb-client

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions