-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Briefly describe arguments for model.model_dump()
#11562
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
PR Change SummaryUpdated documentation for
Modified Files
How can I customize these reviews?Check out the Hyperlint AI Reviewer docs for more information on how to customize the review. If you just want to ignore it on this PR, you can add the Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add What is Hyperlint?Hyperlint is an AI agent that helps you write, edit, and maintain your documentation. Learn more about the Hyperlint AI reviewer and the checks that we can run on your documentation. |
CodSpeed Performance ReportMerging #11562 will degrade performances by 6.69%Comparing Summary
Benchmarks breakdown
|
|
please review |
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.
Thanks, a couple changes
docs/concepts/serialization.md
Outdated
| @@ -104,7 +108,7 @@ print(Model(x=['{"a": 1}', '[1, 2]']).model_dump(round_trip=True)) | |||
| The `.model_dump_json()` method serializes a model directly to a JSON-encoded string | |||
| that is equivalent to the result produced by [`.model_dump()`](#modelmodel_dump). | |||
|
|
|||
| See [arguments][pydantic.main.BaseModel.model_dump_json] for more information. | |||
| See the available [arguments][pydantic.main.BaseModel.model_dump_json] for more information. | |||
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.
| See the available [arguments][pydantic.main.BaseModel.model_dump_json] for more information. | |
| See the available [parameters][pydantic.main.BaseModel.model_dump_json] for more information. |
docs/concepts/serialization.md
Outdated
| @@ -21,6 +21,10 @@ serialized, and exported in a number of ways. | |||
|
|
|||
| This is the primary way of converting a model to a dictionary. Sub-models will be recursively converted to dictionaries. | |||
|
|
|||
| By default, the output may contain non-JSON-serializable Python objects. The `mode` argument can be specified as `"json"` to ensure that the output only contains JSON serializable types. Other arguments exist to include or exclude fields, [including nested fields](#advanced-include-and-exclude), or to further customize the serialization behaviour. | |||
|
|
|||
| See the available [arguments][pydantic.main.BaseModel.model_dump] for more information. | |||
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.
| See the available [arguments][pydantic.main.BaseModel.model_dump] for more information. | |
| See the available [parameters][pydantic.main.BaseModel.model_dump] for more information. |
docs/concepts/serialization.md
Outdated
| @@ -839,7 +843,7 @@ print(t.model_dump(include={'id': True, 'value': True})) # (1)! | |||
| 1. `value` excluded from the output because it excluded in `Field`. | |||
|
|
|||
| That being said, setting `exclude` on the field constructor (`Field(exclude=True)`) does not take priority | |||
| over the `exclude_unset`, `exclude_none`, and `exclude_default` parameters on `model_dump` and `model_dump_json`: | |||
| over the `exclude_unset`, `exclude_none`, and `exclude_default` arguments on `model_dump` and `model_dump_json`: | |||
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.
| over the `exclude_unset`, `exclude_none`, and `exclude_default` arguments on `model_dump` and `model_dump_json`: | |
| over the `exclude_unset`, `exclude_none`, and `exclude_default` parameters on `model_dump` and `model_dump_json`: |
|
Thank you for the review @Viicos! I've replaced some (but not all) occurrences of "argument" with "parameter", including those you described. |
|
Thanks for the contribution |
Change Summary
Briefly describe the arguments available for
model.model_dump()in the Serialization concept docs, particularly about themodeargument.Also make a couple of small grammar/consistency tweaks.
Related issue number
None - this is just a small change to the docs.
Checklist
Selected Reviewer: @sydney-runkle