-
Notifications
You must be signed in to change notification settings - Fork 27
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
Pydantic validators raise a pydantic.Validation error instead of raising a tyro.Instantiation error #70
Comments
Thanks for the suggestion @sander76! This is mostly an aesthetics/user-friendliness thing, right? We get an error message either way, we just want it to be formatted as a The easiest solution here would be to drop a If there's a way to pull out the individual validator for a field we could also do it on the output of |
Yes it is. I like the way tyro does the output. And I see the pydantic validators as a powerful way to validate the arguments. |
Okay, I like it! This seems like an easy way to add a lot of argument validation flexibility to tyro, which is nice. :) No worries if not, but if you have time to take a stab at a (even partial) PR I'd appreciate it, otherwise I can experiment with these errors as soon as I catch up on some other responsibilities. |
I will come up with something! 👍 |
Pydantic has strong property validation capabilities that go beyond the capabilities of type Annotations.
Consider the following pydantic model which has a custom validator included:
Tyro doesn't take them into account during model validation which is -I think- taking place somewhere here:
tyro/tyro/_calling.py
Line 99 in a47b2f8
Pydantic does the above validation at model instantiation, which is happening here:
tyro/tyro/_calling.py
Line 217 in a47b2f8
It would be great to leverage the validation rules inside tyro.
The text was updated successfully, but these errors were encountered: