Skip to content

Conversation

@bullfest
Copy link

Description

Using the child-FieldMeta with the matching annotation seem to pick up the correct constraints for constrained union types.

Closes

Fixes #769

@bullfest bullfest requested a review from adhtruong as a code owner October 29, 2025 11:41
@bullfest bullfest changed the title Fix: Use correct field_meta for constrained union types when building field values for coverage fix: Use correct field_meta for constrained union types when building field values for coverage Oct 29, 2025

AFactory = ModelFactory.create_factory(A, __allow_none_optionals__=False)

assert AFactory.build()
Copy link
Author

@bullfest bullfest Oct 29, 2025

Choose a reason for hiding this comment

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

My fix only seems to work for pydantic 2, adding a call to coverage here crashes

Suggested change
assert AFactory.build()
assert AFactory.build()
assert list(AFactory.coverage())

(Note that this also fails on main)

@github-actions
Copy link

Documentation preview will be available shortly at https://litestar-org.github.io/polyfactory-docs-preview/770

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: ModelFactory.coverage doesn't respect constraints on Decimal

1 participant