Skip to content

Conversation

sydney-runkle
Copy link
Contributor

Paired with pydantic/pydantic-core#1638

Addresses the bug reported in #10571

In pydantic, we already don't allow users to apply the strict annotation to union types. This PR ensures that the strict specification on union members is respected (overrides config spec, if necessary).

@github-actions github-actions bot added the relnotes-fix Used for bugfixes. label Feb 24, 2025
Copy link

cloudflare-workers-and-pages bot commented Feb 24, 2025

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 620e0b6
Status: ✅  Deploy successful!
Preview URL: https://573a8393.pydantic-docs.pages.dev
Branch Preview URL: https://fix-union-ser-strict.pydantic-docs.pages.dev

View logs

Comment on lines +1723 to +1727
inner_schema = {**cls._inner_schema, 'strict': strict}
json_schema = core_schema.no_info_after_validator_function(
source, # construct the type
inner_schema, # pyright: ignore[reportArgumentType]
)
Copy link
Contributor Author

@sydney-runkle sydney-runkle Feb 24, 2025

Choose a reason for hiding this comment

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

This is kind of gross, but so is this whole custom core schema construct for secret types

Copy link

codspeed-hq bot commented Feb 24, 2025

CodSpeed Performance Report

Merging #11481 will not alter performance

Comparing fix-union-ser-strict (620e0b6) with main (d4fac86)

Summary

✅ 46 untouched benchmarks

@dmontagu dmontagu merged commit c8acbec into main Feb 25, 2025
23 of 51 checks passed
@dmontagu dmontagu deleted the fix-union-ser-strict branch February 25, 2025 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes-fix Used for bugfixes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants