-
Notifications
You must be signed in to change notification settings - Fork 247
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 handling of UUID
values having UUID.version=None
#981
Conversation
CodSpeed Performance ReportMerging #981 will degrade performances by 14.28%Comparing Summary
Benchmarks breakdown
|
Fixed. Doesn't break Pydantic tests. |
please review |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #981 +/- ##
=======================================
Coverage 93.09% 93.09%
=======================================
Files 106 106
Lines 15830 15830
Branches 26 26
=======================================
Hits 14737 14737
Misses 1086 1086
Partials 7 7
Continue to review full report in Codecov by Sentry.
|
@@ -59,7 +59,7 @@ impl From<u8> for Version { | |||
#[derive(Debug, Clone)] | |||
pub struct UuidValidator { | |||
strict: bool, | |||
version: Option<Version>, | |||
version: Option<usize>, |
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 change avoids the same conversion on every validation call.
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.
Just one tiny suggestion
if !match py_input_version { | ||
Some(py_input_version) => py_input_version == expected_version, | ||
None => false, | ||
} { |
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.
if !match py_input_version { | |
Some(py_input_version) => py_input_version == expected_version, | |
None => false, | |
} { | |
if !matches!(py_input_version, Some(expected_version)) { |
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.
Apparently, this doesn't work. It reports "unused variable: expected_version
" and tests fail.
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.
Yes, the suggestion is an equivalent to
if !match py_input_version {
Some(expected_version) => true,
None => false,
} {
which is not what we want here.
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.
Ah yes sorry, should have wanted:
!matches(py_input_version, Some(v) if v == expected_version)
or
!py_input_version.is_some_and(|v| v == expected_version)
Co-authored-by: David Hewitt <[email protected]>
This reverts commit 4383da7.
Fix pydantic/pydantic#7355 and fix pydantic/pydantic#7537.