Type compatibility with `h11._headers.Header`

Aperta
#173 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

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

Direzione di ricerca

Start in src/wsproto/typing.py and inspect how the Headers alias is defined. Compare it with h11._headers.Headers from version 0.13.0, then verify that the reported mypy error is resolved and that existing checks still pass. Done means wsproto.Header is type-compatible with h11 headers.

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

Descrizione

At the moment, the wsproto.typing.Header type is not compatible with h11._headers.Header which is defined as the following, starting with version 0.13.0:

class Headers(Sequence[Tuple[bytes, bytes]]):
    [...]

The following patch might provide this compatibility:

diff --git a/src/wsproto/typing.py b/src/wsproto/typing.py
index a44b27e..1786501 100644
--- a/src/wsproto/typing.py
+++ b/src/wsproto/typing.py
@@ -1,3 +1,3 @@
-from typing import List, Tuple
+from typing import Sequence, Tuple
 
-Headers = List[Tuple[bytes, bytes]]
+Headers = Sequence[Tuple[bytes, bytes]]

This would fix mypy errors such as:

error: Argument "headers" to "initiate_upgrade_connection" of "WSConnection" has incompatible type "Headers"; expected "List[Tuple[bytes, bytes]]"  [arg-type]

Would that make sense? I can make a PR if necessary.

Lingua principale
Python
Stelle
303
Fork
57
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

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 python-hyper/wsproto

Tutte le issue di python-hyper/wsproto

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.