-
Notifications
You must be signed in to change notification settings - Fork 291
support __pydantic_extra__
when serializing
#576
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
Conversation
CodSpeed Performance ReportMerging #576 Summary
Benchmarks breakdown
|
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## main #576 +/- ##
=======================================
Coverage 94.18% 94.18%
=======================================
Files 95 96 +1
Lines 12974 13019 +45
Branches 24 24
=======================================
+ Hits 12219 12262 +43
- Misses 749 751 +2
Partials 6 6
Continue to review full report in Codecov by Sentry.
|
e416bf8
to
551fa1f
Compare
551fa1f
to
193b998
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.
This looks good to me generally. Can you add some background in the PR description to explain what the new behavior for dataclass and models is, (what was it before, how does this PR change it)
#[derive(Debug, Clone)] | ||
pub(super) enum FieldsMode { | ||
// typeddict with no extra items | ||
SimpleDict, | ||
// a model - get `__dict__` and `__pydantic_extra__` - `GeneralFieldsSerializer` will get a tuple | ||
ModelExtra, | ||
// typeddict with extra items - one dict with extra items | ||
TypedDictAllow, | ||
} |
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.
Nice!
macro_rules! option_length { | ||
($op_has_len:expr) => { | ||
match $op_has_len { | ||
Some(ref has_len) => has_len.len(), | ||
None => 0, | ||
} | ||
}; | ||
} |
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'm guessing this has to be a macro to support multiple input types that have a .len()
without generics / enums?
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 didn't carefully compare TypedDictSerializer to GeneralFieldsSerializer or anything, but generally this looks good to me.
No description provided.