-
Notifications
You must be signed in to change notification settings - Fork 262
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
Rename validation and serialization schema types to be unique #1629
base: main
Are you sure you want to change the base?
Conversation
`validator-` or `serializer-` is prepended, and the existing ones are deprecated.
e1c4af5
to
ec4e4a1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this, I wonder if we should not change validators, and just change the serialization ones to ser-function-plain
etc?
That would still be good enough to make the functional split, without potentially causing a lot of churn in validation error messages.
@@ -148,6 +149,29 @@ combined_serializer! { | |||
} | |||
} | |||
|
|||
fn get_new_type(py: Python, type_: &str) -> PyResult<String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid allocating:
fn get_new_type(py: Python, type_: &str) -> PyResult<String> { | |
fn get_new_type<'a>(py: Python, type_: &'a str) -> PyResult<&'a str> { |
(and then drop the .to_owned()
calls below)
@@ -510,6 +511,30 @@ macro_rules! validator_match { | |||
}; | |||
} | |||
|
|||
fn get_new_type(py: Python, type_: &str) -> PyResult<String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here:
fn get_new_type(py: Python, type_: &str) -> PyResult<String> { | |
fn get_new_type<'a>(py: Python, type_: &'a str) -> PyResult<&'a str> { |
@@ -93,7 +93,7 @@ def my_function(input_value, info): | |||
v.validate_python(42) | |||
|
|||
assert str(exc_info.value) == ( | |||
'1 validation error for function-plain[my_function()]\n' | |||
'1 validation error for validator-function-plain[my_function()]\n' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we should just double-check we're happy with this new format, as it's potentially breaking to downstream test suites and if we change this we should aim to do so once and not again?
(e.g. would it be better if this just read 1 validation error for my_function()
?)
if schema['type'] not in { | ||
'validator-function-before', | ||
'validator-function-after', | ||
'validator-function-wrap', | ||
'validator-function-plain', | ||
}: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exclusion is because these types are no longer supported in serialization, because of the split?
Do we need a similar test for serialization schemas?
validator-
orserializer-
is prepended, and the existing ones are deprecated.Change Summary
Partly fixes pydantic/pydantic#11087.
Related issue number
Checklist
pydantic-core
(except for expected changes)