Skip to content

Official callback guide contains non-runnable Python examples #162

Description

@dajiaohuang

Page and affected package

Problem

Two current code examples on the official Python SDK callback page are not runnable as shown.

1. Persistent-connection example has a comment after a line continuation

The page shows this structure:

event_handler = lark.EventDispatcherHandler.builder("", "") \
    # Register callback handling functions with register_p2 as the prefix.
    .register_p2_card_action_trigger(do_card_action_trigger) \
    .register_p2_url_preview_get(do_url_preview_get) \
    .build()

A backslash cannot be followed by a comment line before the continued expression. Compiling the displayed code raises a SyntaxError at .register_p2_card_action_trigger(...).

2. Webhook example imports from a nonexistent top-level package

The Flask example uses:

from event.callback.model.p2_card_action_trigger import ...
from event.callback.model.p2_url_preview_get import ...

With lark-oapi 1.7.3 installed, those imports raise:

ModuleNotFoundError: No module named 'event'

The corresponding package paths are under lark_oapi.event.callback.model, and the persistent-connection example on the same page already uses that prefix.

Expected behavior

Every official quick-copy callback example should at least parse and import against the supported package version.

Suggested corrections

  • Move the explanatory comment before the builder expression, or use parentheses instead of backslash continuation.
  • Change both webhook imports to lark_oapi.event.callback.model....

I reloaded the deployed page and checked the current rendered examples rather than relying on cached text. I also searched open and closed issues, all pull request states, and repository history for the exact import and continuation symptoms. Issues #90, #112, and #126 concern callback payload/runtime behavior and do not cover these documentation errors.

Activity

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

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