Skip to content

Accept any sequence of header pairs, not just list - #209

Open
zheng-guannan577 wants to merge 5 commits into
python-hyper:mainfrom
zheng-guannan577:fix-headers-173
Open

zheng-guannan577 wants to merge 5 commits into
python-hyper:mainfrom
zheng-guannan577:fix-headers-173

Conversation

@zheng-guannan577

Copy link
Copy Markdown

Headers is now Sequence[tuple[bytes, bytes]], so callers may pass
tuples (or any other sequence) instead of only lists, matching what
h11 accepts at runtime. This picks up the previously reviewed #204,
which the author closed on 2026-11-09 and explicitly offered for
anyone to take over.

The one point left open in the review of #204 was the mypy error
where the sequence is handed to h11, whose stubs only declare a
list. Instead of silencing it with a cast (as #204 did), the
sequence is now materialised with list(headers) at that single
h11 boundary, so mypy src/ is clean with no casts for headers.

Fixes #173

Updated changelog to reflect API-breaking change in version 1.4.0.
Updated header handling to ensure headers are processed as a list of tuples. This change improves type safety and compatibility with the h11 library.
Added tests for handling extra headers in connection requests and improved parameter handling in handshake functions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type compatibility with h11._headers.Header

1 participant