cleanup: remove dead aiohttp vcr compat shim (#2140) - #2166
Conversation
vcrpy 8.2.0+ restored aiohttp 3.14 compatibility — the broken `AsyncStreamReaderMixin` reference was dropped in kevin1024/vcrpy#996 — and `requirements/local.txt` already pins `vcrpy==8.3.0`. The compat shim in `opencontractserver/utils/vcr_replay.py`, its call site in `conftest.py`, the `EnsureAiohttpVcrCompatTests` test class, and the eight-line comment block above the vcrpy pin were therefore dead code. Resolves Open-Source-Legal#2140.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Quick note on the failing Fork PRs run with a restricted default All functional checks are green on this PR:
The |
|
Closing for the same reason as #2165 — consolidating my open PRs. The dead-shim cleanup is preserved on my fork branch and can be reopened anytime. Thanks! |
Summary
Resolves #2140.
ensure_aiohttp_vcr_compat()was a transitional shim that monkey-patchedaiohttp.streams.AsyncStreamReaderMixinback into existence at importtime, so that vcrpy 8.1.1's aiohttp stub could subclass it. The shim is
no longer needed:
(kevin1024/vcrpy#996)
requirements/local.txtalready pinsvcrpy==8.3.0What's removed
opencontractserver/utils/vcr_replay.py— theensure_aiohttp_vcr_compat()function and its call site inside
maybe_vcr_cassette().conftest.py— the import + invocation of the shim at session start(and the 10-line comment block that justified it).
opencontractserver/tests/test_vcr_replay.py— theEnsureAiohttpVcrCompatTestsclass (3 tests) that asserted the shimworked. The class was testing the shim, not vcrpy itself.
requirements/local.txt— the eight-line comment block above thevcrpy pin explaining when to bump / delete the shim. Replaced with a
one-liner that points at issue Investigate Possibly Deprecated VCR.py Helpers #2140 for future readers.
Net diff: −137 / +9 across 5 files.
Verification
mypy --config-file mypy.ini opencontractserver/utils/vcr_replay.py opencontractserver/tests/test_vcr_replay.py conftest.py→
Success: no issues found in 3 source filespython -m unittest opencontractserver.tests.test_vcr_replay→
Ran 35 tests in 0.6s— allNormalizeBodyTests,MatchLlmBodyTests,MaybeVcrCassetteTests,LlmHostsTestspasswith the shim removed and the test class deleted.
python scripts/collate_changelog.py --check→OK: 252 changelog fragment(s) valid(the new fragment included).Why this is safe
The shim existed solely to paper over vcrpy 8.1.1's broken
AsyncStreamReaderMixinreference. With the pin at 8.3.0, importingvcr.stubs.aiohttp_stubs(whichvcr.VCR().use_cassette(...)doeslazily) no longer raises
AttributeError. I confirmed this bycomparing the stub file across vcrpy 8.1.1 vs 8.2.0 vs 8.3.0 — the
offending
class MockStream(asyncio.StreamReader, streams.AsyncStreamReaderMixin)became
class MockStream(asyncio.StreamReader)in 8.2.0+.The shim's only consumers were:
conftest.pyat import time (covered by the test suite).opencontractserver/utils/vcr_replay.py::maybe_vcr_cassette— thelive E2E record/replay harness's belt-and-braces call site, which
ran the shim before importing
vcr. With 8.3.0 the call is ano-op, so removing it changes nothing observable.
Checklist
changelog.d/2140-remove-aiohttp-vcr-shim.removed.mdaddedor comments (per
CLAUDE.md)cleanup/remove-aiohttp-vcr-shim-2140based onupstream/mainat6d8f21ae0