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

TOML file with a bool that is parsed with Tomlkit does not validate in pydantic #393

Closed
tjadevries opened this issue Jan 11, 2025 · 2 comments

Comments

@tjadevries
Copy link

tjadevries commented Jan 11, 2025

Original problem reported with pydantic: pydantic/pydantic#10978
Minimal example that reproduces the problem: https://github.com/bschwedler/pydantic-tomlkit-bool

The problem is: if you have a pydantic dataclass or a pydantic model with a boolean field and you read a toml file with initialization values and initialize the dataclass/model with the resulting dict, then pydantic will report a validation error that states that the corresponding value in the dict is not a boolean.

@frostming
Copy link
Contributor

We store wrapped objects in the parsed result, don't feed it to pydantic validator directly, instead you should use .unwrap() to get the native python objects.

This is intentional to achieve rich style-preserving, closing it now.

@frostming frostming closed this as not planned Won't fix, can't repro, duplicate, stale Jan 14, 2025
@StockwatchDev
Copy link

@frostming thank you for pointing that out. I should have figured that out myself, sorry for the noise.

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

No branches or pull requests

3 participants