Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a default to ResultData, some related cleanup #512

Merged
merged 4 commits into from
Dec 20, 2024

Conversation

samuelcolvin
Copy link
Member

No description provided.

Copy link

cloudflare-workers-and-pages bot commented Dec 20, 2024

Deploying pydantic-ai with  Cloudflare Pages  Cloudflare Pages

Latest commit: c5d06d3
Status: ✅  Deploy successful!
Preview URL: https://6bdff681.pydantic-ai.pages.dev
Branch Preview URL: https://resultdata-default.pydantic-ai.pages.dev

View logs

@@ -178,6 +178,13 @@ def run_sync3() -> None:
assert_type(result.data, Union[Foo, Bar])


MyUnion: TypeAlias = 'Foo | Bar'
union_agent2: Agent[None, MyUnion] = Agent(
result_type=MyUnion, # type: ignore[arg-type]
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need the type ignore here? What's the error?

Copy link
Member Author

Choose a reason for hiding this comment

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

we need the type here so we can enforce the return type. The error is that a union is not a type, but a typeform, docs about waiting for PEP 747 - https://ai.pydantic.dev/results/?h=pep#structured-result-validation

Copy link
Member

@sydney-runkle sydney-runkle left a comment

Choose a reason for hiding this comment

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

Looking good, left a few nit picky comments 👍

samuelcolvin and others added 2 commits December 20, 2024 17:35
Co-authored-by: Sydney Runkle <54324534+sydney-runkle@users.noreply.github.com>
@samuelcolvin samuelcolvin enabled auto-merge (squash) December 20, 2024 17:41
@samuelcolvin samuelcolvin merged commit 9ae0309 into main Dec 20, 2024
15 checks passed
@samuelcolvin samuelcolvin deleted the ResultData-default branch December 20, 2024 17:42
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.

2 participants