Repository navigation
Conversation
Client.publish, Client.request and JetStream.publish annotated their headers as dict[...]. dict is invariant in its value type, so a caller holding a precisely typed dict[str, str] failed type checking even though it works at runtime; this also flagged JetStream.publish's own forwarding of its headers to Client.request. Annotate the parameters, and encode_headers, as Mapping[str, str | list[str]], which is what the code already accepts: it only reads .items() and checks isinstance(value, list). JetStream.publish now also declares the multi-value headers its tests already pass. No runtime change. The type: ignore on the encode_headers call in publish is no longer needed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Client.publish,Client.requestandJetStream.publishannotateheadersasdict[...].dictis invariant in its value type, so callers holding a precisely typeddict[str, str]fail type checking even though it works at runtime:The same mismatch shows up inside the repo:
JetStream.publishforwards itsdict[str, str]headers toClient.request(headers: dict[str, str | list[str]]).This PR annotates those parameters, and
encode_headers, asMapping[str, str | list[str]]. That's what the code already accepts: it only reads.items()and checksisinstance(value, list), andHeaders.__init__already takesMapping[str, str | list[str]].JetStream.publishnow also declares the multi-value headers its own tests pass (test_jetstream.py,test_stream.py).# type: ignore[arg-type]removed: the one on theencode_headerscall inClient.publish, which is no longer needed.list[str]and notSequence[str]:encode_headersonly expandslistvalues, so a tuple would be sent as a single value.