-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Move annotation compatibility errors to validation phase #9999
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
Conversation
Deploying pydantic-docs with
|
| Latest commit: |
fd12aa4
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://34e38efc.pydantic-docs.pages.dev |
| Branch Preview URL: | https://strict-annotation-apps.pydantic-docs.pages.dev |
CodSpeed Performance ReportMerging #9999 will not alter performanceComparing Summary
|
TypeErrors for improper annotationsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
|
We discussed one design pattern here - the That's a tradeoff I'd be willing to debate further in the future, if folks have strong opinions, but I think this is a good step forward for now. |
An attempt at addressing #9988
We apply annotations in 2 ways, in order of preference:
letointlearound an arbitrary function after around anint. This ensures we respect annotation order.We try to be pretty lax with #2, but this can cause problems if even a functional validator applying the given constraint isn't compatible with the inner type. Thus, I've added some support to our builtin functional validators to raise informative error messages when applying a constraint raises a
TypeError.Fix #9988