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
Fix config behavior with plain dataclass #9150
base: main
Are you sure you want to change the base?
Conversation
Deploying pydantic-docs with Cloudflare Pages
|
CodSpeed Performance ReportMerging #9150 will not alter performanceComparing Summary
|
Please review |
Something seems strange here. We seem to have lots of tests in |
I believe it's because we're only testing validation focused settings, and the pydantic/pydantic/_internal/_generate_schema.py Line 1231 in 02ee0f9
But in this case, we also make sure to pass said config to the constructors for |
That being said, I think we could clean this up a bit, I can create an issue for that. |
Right I see. So I don't think this is the right solution, because as you say the config is already pulled from the type into the schema. I think actually if there's a bug, it's probably in core. See https://github.com/pydantic/pydantic-core/blob/e73b2d1edc5c3c062f1e0b381cda29d6ed6e5901/src/serializers/type_serializers/dataclass.rs#L83, where we do pull the config out of the schema to build a dataclass serializer. But why is that config not applying? |
Good question. 30 mins of digging didn't help me much, but I'd be happy to look into this further in core. I still think that we might want this change though, as the schema serializer is what's used in accordance with the relevant settings here? |
I think that in all cases the schema should already contain the config fetched here; in effect doing this seems to me like it plasters over a core bug by sending the same config in twice. So I'd rather we wait to understand the interaction in core before considering this further. |
Fix #8693
Selected Reviewer: @hramezani