Move annotation compatibility errors to validation phase#9999
Merged
sydney-runkle merged 9 commits intomainfrom Jul 31, 2024
Merged
Move annotation compatibility errors to validation phase#9999sydney-runkle merged 9 commits intomainfrom
sydney-runkle merged 9 commits intomainfrom
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
|
Contributor
TypeErrors for improper annotations
Contributor
Author
|
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. |
This was referenced Jul 31, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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