Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

DeprecationWarning with websockets>=14: runtime import of WebSocketClientProtocol

Aperta Adatta ai principianti
#1,666 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

@mac-agent ci sta già lavorando.

Dal 1/4/2026.

  • #1687 di @mac-agent — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
python
Ambito
networking

Direzione di ricerca

Inizia in binance/ws/websocket_api.py, in corrispondenza dell’importazione a runtime di WebSocketClientProtocol, e verifica come viene utilizzata la classe per il type hinting. Riproduci l’avviso con l’esecuzione di pytest interessata, quindi verifica che l’importazione non attivi più l’avviso di deprecazione di websockets 14+ senza modificare il comportamento di WebSocket.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
7.2k
Fork
2.3k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sammchardy/python-binance

Tutte le issue di sammchardy/python-binance

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.