Repository navigation
test: keep pytest collecting under anyio >= 4.15 (BlockingPortal deprecation) - #54
Conversation
…ecation) anyio 4.15 deprecates anyio.abc.BlockingPortal through a lazy import, and starlette 1.6.0 (the latest release) still imports that alias at module scope in testclient.py. Importing fastapi.testclient therefore emits a DeprecationWarning, and filterwarnings = ["error"] aborts pytest during collection (exit 2) before any test runs. This broke both our own CI and the guard-core ecosystem gate's guard-agent consumer job, whose fresh resolution admits anyio 4.15.x (the dev pin is anyio<4.16 since #53). Ignore exactly that warning until starlette ships its master fix (anyio.from_thread.BlockingPortal); the filter is a bridge, not a loophole — any other warning still fails the suite.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe pytest ChangesPytest warning filter
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~3 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The compatibility filter addresses the known Starlette/AnyIO collection warning while other warnings continue to fail the test suite. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Closes #55
Root cause
filterwarnings = ["error"]+ two upstream facts collide:anyio<4.16since Update anyio requirement from <4.15 to <4.16 in the dependencies group #53) deprecatesanyio.abc.BlockingPortalvia its new lazy-import machinery (anyio/_lazyimport.py) and emits aDeprecationWarningon first attribute access.testclient.py:53.So
import fastapi.testclient— done bytests/test_adapter_fastapi.pyandtests/test_performance.py— raises the warning at collection time, theerrorfilter promotes it to an exception, and pytest exits 2 before running a single test.Since this repo ships no
uv.lock(gitignored), both our own CI (uv sync --extra dev) and the guard-core ecosystem gate resolve fresh, so any environment built after anyio 4.15's release reproduces this:2 errors during collection, exit 2 on base and candidate.Fix
One targeted
filterwarningsentry ignoring exactly that message (DeprecationWarning, prefix-matched), with a comment noting the removal condition. Everything else still fails the suite — the warnings-as-errors contract from b1f62d0 stays intact.Capping
anyio<4.15again would only re-fight dependabot and delay the same crash. starlette master already switched toanyio.from_thread.BlockingPortal, so drop this filter once a starlette release > 1.6.0 lands — the comment inpyproject.tomlsays so.Verification
Gate-identical environment (fresh
uv lockresolution: anyio 4.15.1, starlette 1.6.0, fastapi 0.141.1, Python 3.10.19):pytest tests/test_adapter_fastapi.py --collect-only→ exit 2,2 errors during collection(matches the CI traceback byte-for-byte).