Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Type compatibility with h11._headers.Header #173

Open
@vxgmichel

Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /