Skip to content
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

Merged
merged 6 commits into from Oct 23, 2019

Conversation

@dmontagu
Copy link
Collaborator

dmontagu commented Oct 21, 2019

Change Summary

Rename skip_defaults to exclude_unset, and add exclude_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

  • Unit tests for the changes exist
  • Tests pass on CI and coverage remains at 100%
  • Documentation reflects the changes where applicable
  • changes/<pull request or issue id>-<github username>.md file added describing change
    (see changes/README.md for details)
pydantic/main.py Show resolved Hide resolved
@codecov

This comment has been minimized.

Copy link

codecov bot commented Oct 21, 2019

Codecov Report

Merging #915 into master will not change coverage.
The diff coverage is n/a.

@@          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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f5cde39...1c64181. Read the comment docs.

pydantic/main.py Show resolved Hide resolved
pydantic/main.py Show resolved Hide resolved
docs/usage/exporting_models.md Show resolved Hide resolved
pydantic/main.py Show resolved Hide resolved
@@ -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"',

This comment has been minimized.

Copy link
@samuelcolvin

samuelcolvin Oct 21, 2019

Owner
Suggested change
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"',

?

pydantic/main.py Show resolved Hide resolved
pydantic/main.py Outdated Show resolved Hide resolved
@dmontagu dmontagu mentioned this pull request Oct 21, 2019
4 of 4 tasks complete
pydantic/main.py Outdated Show resolved Hide resolved
@samuelcolvin

This comment has been minimized.

Copy link
Owner

samuelcolvin commented Oct 21, 2019

need tests for the warning raise by skip_defaults and that it does the same thing as exclude_defaults

@samuelcolvin

This comment has been minimized.

Copy link
Owner

samuelcolvin commented Oct 21, 2019

also need a change file.

@samuelcolvin

This comment has been minimized.

Copy link
Owner

samuelcolvin commented Oct 22, 2019

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.

@dmontagu dmontagu force-pushed the dmontagu:rename-skip-defaults branch from 263f9af to 1c64181 Oct 23, 2019
@samuelcolvin samuelcolvin merged commit 6b5adcc into samuelcolvin:master Oct 23, 2019
10 checks passed
10 checks passed
Header rules No header rules processed
Details
Pages changed 5 new files uploaded
Details
Redirect rules No redirect rules processed
Details
Mixed content No mixed content detected
Details
codecov/project 100% remains the same compared to f5cde39
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
deploy/netlify Deploy preview ready!
Details
samuelcolvin.pydantic Build #20191023.3 succeeded
Details
samuelcolvin.pydantic (Job Python36) Job Python36 succeeded
Details
samuelcolvin.pydantic (Job Python37) Job Python37 succeeded
Details
@samuelcolvin

This comment has been minimized.

Copy link
Owner

samuelcolvin commented Oct 23, 2019

awesome, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.