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

fix pydantic ValidationError when loading .env file #28

Merged
merged 1 commit into from
Nov 2, 2023

Conversation

VallariAg
Copy link
Member

By default extra=forbid is used, which raises ValidationError
when there are variables in .env which are not defined in
APISettings as attributes.
Solution: extra=ignore would not raise errors for new env variables
in .env file and load all of them.
ref: https://docs.pydantic.dev/latest/concepts/pydantic_settings/#:~:text=you%20should%20use-,extra%3Dignore,-%3A

fixes: #25

By default extra=forbid is used, which raises ValidationError
when there are variables in .env which are not defined in
`APISettings` as attributes.
Solution: extra=ignore would not raise errors for new env variables
in .env file and load all of them.
ref: https://docs.pydantic.dev/latest/concepts/pydantic_settings/#:~:text=you%20should%20use-,extra%3Dignore,-%3A

fixes: #25

Signed-off-by: Vallari Agrawal <[email protected]>
@VallariAg VallariAg requested a review from zmc November 2, 2023 06:25
Copy link
Member

@zmc zmc left a comment

Choose a reason for hiding this comment

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

Thanks!

@zmc zmc merged commit f92d3f3 into main Nov 2, 2023
3 checks passed
@zmc zmc deleted the fix-pydantic-env-error branch November 2, 2023 19:00
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.

Pydantic errors when using a .env file
2 participants