Skip to content

Conversation

cmenon12
Copy link
Contributor

@cmenon12 cmenon12 commented Mar 15, 2025

Change Summary

Briefly describe the arguments available for model.model_dump() in the Serialization concept docs, particularly about the mode argument.

Also make a couple of small grammar/consistency tweaks.

Related issue number

None - this is just a small change to the docs.

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review, please add a comment including the phrase "please review" to assign reviewers

Selected Reviewer: @sydney-runkle

Copy link
Contributor

hyperlint-ai bot commented Mar 15, 2025

PR Change Summary

Updated documentation for model.model_dump() to clarify the available arguments, particularly the mode argument, and made minor grammatical adjustments for consistency.

  • Described the mode argument in the context of model.model_dump() for better clarity.
  • Added a note about JSON serialization in the serialization documentation.
  • Improved consistency in terminology related to arguments in the documentation.

Modified Files

  • docs/concepts/serialization.md

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 hyperlint-ignore label to the PR. Future changes won't trigger a Hyperlint review.

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 hyperlint-ignore to the PR to ignore the link check for this PR.

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.

Copy link
Contributor

github-actions bot commented Mar 15, 2025

Coverage report

This PR does not seem to contain any modification to coverable code.

Copy link

codspeed-hq bot commented Mar 15, 2025

CodSpeed Performance Report

Merging #11562 will degrade performances by 6.69%

Comparing cmenon12:cmenon12-serialization-docs (83a4fca) with main (a2846da)

Summary

❌ 1 regressions
✅ 45 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
test_model_validators_serializers 767.7 µs 822.7 µs -6.69%

@cmenon12
Copy link
Contributor Author

please review

Copy link
Member

@Viicos Viicos left a 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

@@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

@@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
See the available [arguments][pydantic.main.BaseModel.model_dump] for more information.
See the available [parameters][pydantic.main.BaseModel.model_dump] for more information.

@@ -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`:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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`:

@cmenon12
Copy link
Contributor Author

Thank you for the review @Viicos! I've replaced some (but not all) occurrences of "argument" with "parameter", including those you described.

@cmenon12 cmenon12 requested a review from Viicos March 18, 2025 20:50
@Viicos Viicos enabled auto-merge (squash) March 19, 2025 10:16
@Viicos
Copy link
Member

Viicos commented Mar 19, 2025

Thanks for the contribution

@Viicos Viicos merged commit 7b8fd9a into pydantic:main Mar 19, 2025
61 of 62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants