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

Update dataclass docs to indicate support for extra config #7375

Merged
merged 2 commits into from Sep 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 4 additions & 5 deletions docs/usage/dataclasses.md
Expand Up @@ -138,11 +138,10 @@ class MyDataclass2:
1. You can read more about `validate_assignment` in [model_config](model_config.md#validate-assignment).

!!! note
Pydantic dataclasses do not support [`extra='allow'`](model_config.md#extra-attributes), where extra fields passed
to the initializer would be stored as extra attributes on the dataclass.

`extra='ignore'` is still supported for the purpose of ignoring
unexpected fields while parsing data; they just won't be stored on the instance.
Pydantic dataclasses support [`extra`](model_config.md#extra-attributes) configuration to `ignore`, `forbid`, or
`allow` extra fields passed to the initializer. However, some default behavior of stdlib dataclasses may prevail.
For example, any extra fields present on a Pydantic dataclass using `extra='allow'` are omitted when the dataclass
is `print`ed.

## Nested dataclasses

Expand Down