{{ message }}
Repository navigation
➖ Drop pydantic-ai dependency, use pydantic-ai-slim[openai] instead - #16526
Open
YuriiMotov wants to merge 2 commits into
Open
YuriiMotov wants to merge 2 commits into
YuriiMotov wants to merge 2 commits into
Conversation
Contributor
📝 Docs previewLast commit b9821e9 at: https://5a1625d6.fastapitiangolo.pages.dev |
YuriiMotov
force-pushed
the
switch-to-pydantic-ai-slim
branch
from
October 19, 2026 12:40
abe9424 to
b9821e9
Compare
YuriiMotov
commented
Oct 19, 2026
|
|
||
| { include-group = "docs-tests" }, | ||
| "anyio[trio] >=3.2.1,<5.0.0", | ||
| "anyio[trio] >=4.1.0,<5.0.0", |
Member
Author
There was a problem hiding this comment.
The following code requires AnyIO >= 4.0.0.
Lines 615 to 617 in f632658
See the MRE
from collections.abc import AsyncIterator
from fastapi import FastAPI
from fastapi.responses import EventSourceResponse
from fastapi.testclient import TestClient
app = FastAPI()
@app.get("/events", response_class=EventSourceResponse)
async def events() -> AsyncIterator[str]:
yield "hello"
with TestClient(app) as client:
response = client.get("/events")
print(response.text)The code example above works well with latest versions, but fails if you install AnyIO < 4.0.0
And with AnyIO < 4.1.0 we have several:
TypeError: run_sync() got an unexpected keyword argument 'cancellable'
This branch has not been deployed
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.

Description
We don't actually need the full
pydantic-aipackage.I checked translation works well with just
pydantic-ai-slim[openai].It allows us to drop 41 sub-dependencies and avoid some useless Dependabot PRs like this.
Note: dropping the full
pydantic-aiexposed an issue - FastAPI doesn't declare AnyIO as dependency, but actually uses it. Currently it's a sub-dependency of Starlette and if we install project with lowest depenencies, it will install AnyIO 3.X which is incompatible with how it's used in FastAPI. See the comment.I only updated the min version in
testdependencies - just to resolve failing CI, but we should probably add AnyIO as main dependency.AI Disclaimer
Used Codex (Astra) to double-check
Checklist