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.
Page and affected package
2025-03-28lark-oapi1.7.3 /0b9e6e48b74bb4b34462fc67b7e738b27e73e697Problem
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:
A backslash cannot be followed by a comment line before the continued expression. Compiling the displayed code raises a
SyntaxErrorat.register_p2_card_action_trigger(...).2. Webhook example imports from a nonexistent top-level package
The Flask example uses:
With
lark-oapi1.7.3 installed, those imports raise: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
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.