-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add merged json_encoders inheritance #2064
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
Add merged json_encoders inheritance #2064
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2064 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 23 23
Lines 4426 4426
Branches 888 888
=========================================
Hits 4426 4426 Continue to review full report at Codecov.
|
e6e61e7 to
904aeb9
Compare
samuelcolvin
left a comment
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.
you need to add a change description and update the docs to describe the new behaviour preferably with an example
pydantic/main.py
Outdated
| json_encoders = { | ||
| **getattr(parent_config, 'json_encoders', {}), | ||
| **getattr(self_config, 'json_encoders', {}), | ||
| } | ||
| namespace['json_encoders'] = json_encoders |
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.
| json_encoders = { | |
| **getattr(parent_config, 'json_encoders', {}), | |
| **getattr(self_config, 'json_encoders', {}), | |
| } | |
| namespace['json_encoders'] = json_encoders | |
| namespace['json_encoders'] = { | |
| **getattr(parent_config, 'json_encoders', {}), | |
| **getattr(self_config, 'json_encoders', {}), | |
| } |
Thanks for the feedback @samuelcolvin ! |
|
@art049, I'm happy to accept this change. We still need a change description and docs. |
|
@art049 are you okay to fix this? |
82e0990 to
fd76fb6
Compare
6e00308 to
7039b05
Compare
@samuelcolvin yes, totally. WDYT about the docs? I don't know if it explains the feature properly enough |
7039b05 to
0b9ae26
Compare
0b9ae26 to
3865c7b
Compare
|
great, thank you so much. |
Change Summary
While inheriting the configuration , the
json_encodersdictionaries are merged and the child classes can still override an encoder defined in the parent class.Related issue number
Fixes #2024
Checklist
changes/<pull request or issue id>-<github username>.mdfile added describing change(see changes/README.md for details)