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

Bugfix/make sure excluded fields are excluded #1

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

om-henners
Copy link

Ran into this issue when dumping from a model with excluded fields and those fields showed up. Basically the exclude attribute on a field is standard and filters the field entirely from output when dumping via item.model_dump(). But we weren't filtering field names at the same time which led to broken output. This fixes the issue by filtering out those fields from the fieldnames as well.

Henry Walshaw added 6 commits September 12, 2024 14:04
From the
[docs](https://docs.pydantic.dev/latest/concepts/fields/#exclude):

> The `exclude` parameter can be used to control which fields should
> be excluded from the model when exporting the model.

At the moment the values are excluded as expected, but the headers are
not correctly filtered. This is worse than we expect because it also
breaks the order of the fields rather than leaving the field blank.
This involves switching to a dict writer, and making user whether to
use aliases is passed through to the write method.
@om-henners om-henners force-pushed the bugfix/make_sure_excluded_fields_are_excluded branch from 8758b42 to 334f400 Compare September 17, 2024 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant