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

Forbid extra fields in Pydantic models #43

Merged
merged 5 commits into from
Feb 21, 2024
Merged

Conversation

mmwinther
Copy link
Member

By default, Pydantic allows extra fields to be set on model instantiation. This can lead to some very 🌶️ spicy 🌶️ bugs as a typo can prevent data being saved correctly, and this won't be picked up by any code quality tools.

This change will raise a ValidationError if an unknown field is set (see the unit test).

@mmwinther mmwinther requested review from BjornRoarJoneid and a team as code owners February 21, 2024 09:15
@github-actions github-actions bot added bug Something isn't working python Updates to the generated Python project labels Feb 21, 2024
@mmwinther mmwinther merged commit 61f25c2 into main Feb 21, 2024
2 checks passed
@mmwinther mmwinther deleted the fix/forbid-extra-fields branch February 21, 2024 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python Updates to the generated Python project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants