-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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 skip-defaults, and add ability to exclude actual defaults #915
Conversation
Codecov Report
@@ Coverage Diff @@
## master #915 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 16 16
Lines 2799 2799
Branches 543 543
=====================================
Hits 2799 2799 Continue to review full report at Codecov.
|
pydantic/main.py
Outdated
@@ -345,8 +358,20 @@ def json( | |||
|
|||
`encoder` is an optional function to supply as `default` to json.dumps(), other arguments as per `json.dumps()`. | |||
""" | |||
if skip_defaults is not None: | |||
warnings.warn( | |||
f'{type(self).__name__}.dict: "skip_defaults" is deprecated and replaced by "exclude_unset"', |
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.
f'{type(self).__name__}.dict: "skip_defaults" is deprecated and replaced by "exclude_unset"', | |
f'{type(self).__name__}.json: "skip_defaults" is deprecated and replaced by "exclude_unset"', |
?
need tests for the warning raise by |
also need a change file. |
I think this is the only thing v1 is waiting for. If possible it would be great if this could get finished. Otherwise hope you don't if I push to this PR to finish it tomorrow. |
263f9af
to
1c64181
Compare
awesome, thank you. |
…antic#915) * Rename skip-defaults, and add ability to exclude actual defaults * Add __defaults__ and deprecation warnings * Add note about `skip_defaults` to docs * Incorporate feedback * Add tests and changes * Fix reference to .json()
**Description of PR** Currently, we are setting both `skip_defaults` and `exclude_unset` when we call Pydantic's `json` method. The former was made a (deprecated) alias for the latter in pydantic/pydantic#915, released [as part of v1.0](https://github.com/pydantic/pydantic/blob/main/HISTORY.md#v10-2019-10-23); we have a minimum requirement of v1.7. This PR removes the redundant `skip_defaults` parameter. Signed-off-by: Alice Purcell <alicederyn@gmail.com> Co-authored-by: Elliot Gunton <elliotgunton@gmail.com>
Change Summary
Rename
skip_defaults
toexclude_unset
, and addexclude_defaults
argument.Still need to add tests and docs, but I wanted to get some feedback on the approach first.
Related issue number
fix #523
Checklist
changes/<pull request or issue id>-<github username>.md
file added describing change(see changes/README.md for details)