Skip to content

lazy parameter missing from type hints for event(), message(), etc. #1412

@quicksilversel

Description

@quicksilversel

Reproducible in:

The slack_bolt version

slack-bolt==1.26.0
slack-sdk==3.34.0

Python runtime version

Python 3.12.0

OS info

ubuntu-latest (but reproducible on any OS)

Steps to reproduce:

  1. Create a file with a lazy listener:
from slack_bolt import App

app = App(token="xoxb-xxx", signing_secret="xxx")

def process_mention(event, say, logger):
    say("Hello!")

@app.event("app_mention", lazy=[process_mention])
def handle_mention():
    pass
  1. Run mypy:
mypy your_file.py
  1. Observe error

Expected result:

No mypy error. The lazy parameter is a valid, documented feature and should be included in the type signature.

Actual result:

your_file.py:9: error: Unexpected keyword argument "lazy" for "event" of "App"  [call-arg]

Root cause: The lazy parameter is handled via **kwargs in the inner call function (app.py line 846), but it's not declared in the event() method signature. Same issue affects message(), action(), command(), etc.

Suggested fix: Add lazy to the method signatures:

def event(
    self,
    event: ...,
    matchers: ... = None,
    middleware: ... = None,
    lazy: Optional[Sequence[Callable[..., Optional[BoltResponse]]]] = None,
) -> ...:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions