Skip to content

fix: Support pydantic examples in nested type annotations#852

Open
bullfest wants to merge 1 commit into
litestar-org:mainfrom
bullfest:main
Open

fix: Support pydantic examples in nested type annotations#852
bullfest wants to merge 1 commit into
litestar-org:mainfrom
bullfest:main

Conversation

@bullfest

@bullfest bullfest commented May 10, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #851

I'm not sure what the preferred design should be when there's examples on both a parent and a child, but I opted for the parent shadowing the child's examples.
I believe this is how .build() behaves, and I think this makes sense as you wouldn't want the child's examples to be used if you add additional constraints to a type with a custom validator (that would require you to use examples to help polyfactory generate allowed values).

@bullfest bullfest requested a review from adhtruong as a code owner May 10, 2026 10:23
@bullfest bullfest changed the title Fix: Support pydantic examples in nested type annotations fix: Support pydantic examples in nested type annotations May 10, 2026
@sander76

sander76 commented May 14, 2026

Copy link
Copy Markdown

I think the issue you're solving is a broader one. It does not only limit itself to pydantic examples. It involves any other constraint added to the Annotated type. See this ticket too: #854

I was wrong.

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.

Bug: Examples in union types are not found when using coverage

2 participants