Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Avoid deprecated anyio.abc.BlockingPortal alias in testclient - #3500

Closed
kishansaaai wants to merge 2 commits into
Kludex:mainfrom
kishansaaai:fix-testclient-blocking-portal-deprecation
Closed

Avoid deprecated anyio.abc.BlockingPortal alias in testclient#3500
kishansaaai wants to merge 2 commits into
Kludex:mainfrom
kishansaaai:fix-testclient-blocking-portal-deprecation

Conversation

@kishansaaai

@kishansaaai kishansaaai commented Sep 3, 2026

Copy link
Copy Markdown

Summary

starlette.testclient used the anyio.abc.BlockingPortal alias, which was formally deprecated in AnyIO 4.15.0 in favor of anyio.from_thread.BlockingPortal (agronholm/anyio#1169).

Because _PortalFactoryType is evaluated at module load time (starlette/testclient.py:53), importing starlette.testclient under AnyIO 4.15.0 emitted a DeprecationWarning: The anyio.abc.BlockingPortal alias is deprecated, use anyio.from_thread.BlockingPortal instead.. When downstream test suites (e.g., in pydantic-ai) run under filterwarnings = ["error"], test collection failed on import.

This replaces the three occurrences of anyio.abc.BlockingPortal with anyio.from_thread.BlockingPortal and adds a regression test ensuring TestClient and importing starlette.testclient emit no DeprecationWarning.

Fixes #3497

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread tests/test_testclient.py Outdated
@codspeed-hq

codspeed-hq Bot commented Sep 3, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 242 untouched benchmarks


Comparing kishansaaai:fix-testclient-blocking-portal-deprecation (1518a2a) with main (39fd0ff)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

testclient imports the deprecated anyio.abc.BlockingPortal alias

2 participants