python / python/typeshed

Question - how to write a stub file with missing imports?

オープン
#14,867 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

主要言語
Python
スター
5.1k
フォーク
2.1k
平均マージ
1日 19時間
マージ済み PR(30日)
82

説明

I'm working on adding engineio to typeshed, and in its source code there is a file which imports from eventlet without a guard - https://github.com/miguelgrinberg/python-engineio/blob/main/src/engineio/async_drivers/eventlet.py#L1-L3.
the guard is in another part of the code - https://github.com/miguelgrinberg/python-engineio/blob/main/src/engineio/base_server.py#L82-L92

eventlet isn't even an optional dependency of engineio, but if it's installed and configured properly then the user's code can use engineio's eventlet driver

how should I approach this in the stub file of engineio/async_drivers/eventlet.pyi? I can't import from eventlet since it's not a dependency, but I also can't define the class WebSocketWSGI which inherits from the import eventlet.websocket.WebSocketWSGI

one possibility I've though of is to write a protocol which behaves like eventlet.websocket.WebSocketWSGI but that doesn't seem like the best approach...

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

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

はじめの一歩

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

調査の方向性

typeshed's engineio/async_drivers/eventlet.pyi から始め、リンク先の python-engineio ソースにある eventlet.py と比較します。engineio/base_server.py のガードされた import を読み、このドライバーがいつ利用可能になるのかを理解します。欠落している eventlet 依存関係に対して、サポートされる stub のアプローチを選択して文書化できれば完了です。

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

評価

技術スタック
python
領域
devtools
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

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

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