Repository navigation
fix(tests): skip aiohttp stub patches that fixed VCR.py doesn't need - #834
Merged
Abhijeet Prasad (AbhiPrasad) merged 1 commit intoOct 2, 2026
Conversation
_patch_vcr_aiohttp_stubs() works around kevin1024/vcrpy#927 and kevin1024/vcrpy#502. kevin1024/vcrpy#1055 fixes both in VCR.py and makes MockStream aiohttp's StreamReader, which takes the body. The cached content property then calls MockStream() without one, so every aiohttp replay fails with a TypeError and pylint reports E1120. Skip the content property, the no-op set_exception and the record_response replacement when MockStream is a StreamReader, which is only true with that fix. VCR.py 8.3.0 gets the same patches as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GwUvhmzgfkiZ6vo4uGyesN
Member
|
hey thanks for the PR! What led you to make this change? |
Contributor
Author
hey, np! Just happened to fix vcrpy, and stumbled upon this :) . Some more context in kevin1024/vcrpy#1055 |
Abhijeet Prasad (AbhiPrasad)
approved these changes
Oct 2, 2026
Abhijeet Prasad (AbhiPrasad)
merged commit Oct 2, 2026
6dd5034
into
braintrustdata:main
83 checks passed
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.
Summary
_patch_vcr_aiohttp_stubs()inpy/src/braintrust/conftest.pyworks around kevin1024/vcrpy#927 and kevin1024/vcrpy#502. kevin1024/vcrpy#1055 (not released yet) fixes both and makesMockStreamaiohttp'sStreamReader, which takes the body. Our cachedcontentproperty then callsMockStream()without a body, so aiohttp replays fail withTypeError: MockStream.__init__() missing 1 required positional argument: 'body', and pylint reports E1120. Nothing fails yet becausepy/uv.lockpins VCR.py 8.3.0, but the first weekly lock upgrade after a release with the fix would.Changes
MockStreamis aiohttp'sStreamReader, which only happens with the fix, skip the cachedcontentproperty, the no-opset_exceptionand therecord_responsereplacement. The fix isn't released yet, so a version number can't identify it, hence the class check. Thestream_writer,iter_chunkedand gziptext()/read()patches stay.no-value-for-parameteron theMockStream()call that only older VCR.py reaches.On 8.3.0 the same attributes get the same code. With the fix,
response.contentis no longer gunzipped, which none of the 1,909 recorded responses needs.Testing
Each nox session's tests, replaying cassettes with
CI=1:test_litellmlatest, 1.74.0test_huggingface_hub(0.32.0)test_google_adklatest, 2.6.3, 1.14.1test_google_genai(latest)with aiohttppylint --errors-onlyRecording LiteLLM, google-genai and huggingface_hub calls against a local server and replaying them also works on both versions. No new test: these sessions already reproduce the failure. Pre-commit hooks pass.
🤖 Generated with Claude Code
https://claude.ai/code/session_01GwUvhmzgfkiZ6vo4uGyesN