refactor: remove _build_headers() side effect in Anthropic client#163
Merged
Kamilbenkirane merged 1 commit intomainfrom Feb 22, 2026
Merged
Conversation
Move request_body.pop("_beta_features") to the two call sites
(_make_request, _make_stream_request) so _build_headers() becomes a
pure function. Also switches _build_headers() to use _json_headers()
from APIMixin as its base, removing the duplicated auth + Content-Type
header construction and the ApplicationMimeType import.
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
Merged
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.
Closes #159
Summary
_build_headers()no longer acceptsrequest_body— it is now a pure function with signature_build_headers(beta_features: list[str] | None = None)request_body.pop("_beta_features", [])is moved to the two call sites (_make_request,_make_stream_request), making the mutation visible where it happens_build_headers()now callsself._json_headers()(fromAPIMixin, added in refactor: add _json_headers() helper to APIMixin #162) as its base instead of duplicating the auth +Content-Typeheader construction inlineApplicationMimeTypeimportTest plan
_beta_featuresis still stripped from the request body before the HTTP call and translated into theanthropic-betaheader