You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@pytest_asyncio.fixture
async def deprecated_client(deprecated_db_manager: MainDbManager) -> AsyncGenerator[AsyncClient, None]:
async with _make_mocked_test_app(db_manager=deprecated_db_manager, authorization=False) as app:
- async with AsyncClient(app=app, base_url=URL, headers=USER_AGENT) as ac:+ async with AsyncClient(transport=ASGITransport(app), base_url=URL, headers=USER_AGENT) as ac:
yield ac
% poetry run mypy .
tests/conftest.py:64: error: Argument 1 to "ASGITransport" has incompatible type "FastAPI"; expected "Callable[[dict[str, Any], Callable[[], Awaitable[dict[str, Any]]], Callable[[dict[str, Any]], Coroutine[None, None, None]]], Coroutine[None, None, None]]" [arg-type]
tests/conftest.py:64: note: "FastAPI.__call__" has type "Callable[[Arg(MutableMapping[str, Any], 'scope'), Arg(Callable[[], Awaitable[MutableMapping[str, Any]]], 'receive'), Arg(Callable[[MutableMapping[str, Any]], Awaitable[None]], 'send')], Coroutine[Any, Any, None]]"
Found 1 error in 1 file (checked 472 source files)
It looks like FastAPI and httpx disagree on the shape of an ASGI application. How am I meant to resolve this?
The text was updated successfully, but these errors were encountered:
The code sample in `docs_src/async_tests/test_main.py` triggers the
following deprecation warning with recent versions of `httpx`:
DeprecationWarning: The 'app' shortcut is now deprecated.
Use the explicit style 'transport=ASGITransport(app=...)' instead.
We fix it as suggested by the warning.
Note that due to encode/httpx#3111 the new way
of creating `AsyncClient` passes type checks only when using httpx
version 0.27.2 or newer. This is not a problem for FastAPI itself though
because it does not type check code samples.
The text was updated successfully, but these errors were encountered: