Official callback guide contains non-runnable Python examples

オープン 初心者向け
#162 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
ドキュメント
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
documentation

調査の方向性

リンク先のFeishuページにある公式callbackガイドから始め、そこにある永続接続とwebhookの例をlark-oapi 1.7.3と比較します。修正したスニペットを、永続接続の例をコンパイルし、対応パッケージからwebhookモデルをインポートして確認します。両方のクイックコピー例がエラーなく解析およびインポートできれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
559
フォーク
102
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

larksuite/oapi-sdk-python のほかの issue

larksuite/oapi-sdk-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。