-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
cattrs.structure
is failing detailed_validation=True
behavior with validations
#440
Comments
You're mixing attrs validators and cattrs here. It's not a mistake or anything, but you should be aware attrs validators don't aggregate all errors; they short-circuit on the first one. You can see this if you try instantiating your model directly:
So there's nothing we can do directly here. cattrs doesn't disable attrs validators for various reasons. There is an effort underway to add a better validation framework to cattrs though, which would probably solve your issue. Right now cattrs will validate the shape of your data (if a field is annotated as an |
@Tinche |
It's coming in 24.1, I think in 3-6 months. Sorry :/ |
No need to apologize. I can work around the issue as proper a engineer should haha. This will give me a chance to get better familiarized with exception attributes. With a little bit of intuition I can have something working soon. |
I was OK with keeping this open and marked as an enhancement request until we implement this validation, up to you. |
Sure, yeah. I just didn't think of it as an immediate issue. But if it helps to mark as a request then let's do that. |
Description
cattrs.structure
is seemingly failing to properly aggregate validation failures, even when explicitly settingdetailed_validation=True
on new converter.What I Did
This will result in
['invalid value @ $']
which is unexpected.If I print out the exceptions from
e
:(ValueError("'test_data_1' must be < 100: 110.0"),)
Unless I'm missing something very critical, this seems like a bug.
The text was updated successfully, but these errors were encountered: