Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

DeprecationWarning with websockets>=14: runtime import of WebSocketClientProtocol

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

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
python
領域
networking

調査の方向性

binance/ws/websocket_api.py の WebSocketClientProtocol の実行時インポートから始め、型付けのためにクラスがどのように使用されているかを確認します。影響を受ける pytest の実行で警告を再現し、その後、WebSocket の動作を変更せずに、インポートによって websockets 14+ の非推奨警告が発生しなくなったことを確認します。

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

説明

Hi 👋

With python-binance==1.0.34 and websockets>=14, importing the websocket client triggers deprecation warnings:

--- Start ---
.venv/lib/python3.14t/site-packages/binance/ws/websocket_api.py:4
/home/ubuntu/nnf_beta/.venv/lib/python3.14t/site-packages/binance/ws/websocket_api.py:4: DeprecationWarning: websockets.WebSocketClientProtocol is deprecated
from websockets import WebSocketClientProtocol # type: ignore

.venv/lib/python3.14t/site-packages/websockets/legacy/init.py:6
/home/ubuntu/nnf_beta/.venv/lib/python3.14t/site-packages/websockets/legacy/init.py:6: DeprecationWarning: websockets.legacy is deprecated; see https://websockets.readthedocs.io/en/stable/howto/upgrade.html for upgrade instructions
warnings.warn( # deprecated in 14.0 - 2024-11-09

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
--- End ---

This comes from a runtime import in:
binance/ws/websocket_api.py

from websockets import WebSocketClientProtocol

According to the websockets 14+ upgrade notes, WebSocketClientProtocol and
websockets.legacy are deprecated and scheduled for removal.

The warning is triggered on import, even when the class is only used for typing.
This shows up clearly during pytest runs.

A short-term fix could be to guard the import behind typing.TYPE_CHECKING
(or similar), which would remove the runtime warning without changing behavior.

Longer-term, a migration to the new websockets asyncio API may be needed,
but I wanted to report this early since it will eventually become a hard failure.

Environment:

  • python-binance==1.0.34
  • websockets>=14
  • Python 3.12 / 3.13 / 3.14-dev (reproduces across versions)

Happy to open a PR for a minimal fix if this approach is acceptable.

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

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

sammchardy/python-binance のほかの issue

sammchardy/python-binance の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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