Skip to content

Conversation

sydney-runkle
Copy link
Contributor

Fix #10151

I suppose you could say this is contributing to #10036

Admittedly, this adds another custom wrap validator which is slower, but I think the behavior is better, and this is for a case that's already slow.

@sydney-runkle sydney-runkle requested a review from adriangb August 16, 2024 15:23
@github-actions github-actions bot added the relnotes-fix Used for bugfixes. label Aug 16, 2024
Copy link

cloudflare-workers-and-pages bot commented Aug 16, 2024

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: e16d6ee
Status: ✅  Deploy successful!
Preview URL: https://aaae9df8.pydantic-docs.pages.dev
Branch Preview URL: https://more-verbose-error-annotatio.pydantic-docs.pages.dev

View logs

Copy link

codspeed-hq bot commented Aug 16, 2024

CodSpeed Performance Report

Merging #10158 will not alter performance

Comparing more-verbose-error-annotations (e16d6ee) with main (ed54f28)

Summary

✅ 17 untouched benchmarks

@sydney-runkle sydney-runkle added relnotes-change Used for changes to existing functionality which don't have a better categorization. and removed relnotes-fix Used for bugfixes. labels Aug 16, 2024
@sydney-runkle sydney-runkle changed the title Add more helpful errors for chain schema annotations Improve runtime errors for string constraints like pattern for incompatible types Aug 16, 2024
Copy link
Member

@adriangb adriangb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a clear improvement to me :)

Comment on lines +249 to +254
if 'type' in ve.errors()[0]['type']:
raise TypeError(
f"Unable to apply constraint '{constraint}' to supplied value {value} for schema of type '{schema_type}'" # noqa: B023
)
raise ve
return x
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add an example here in a comment? It's not clear to me what the goal is just looking at hte code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks for the tip!

Copy link
Contributor

github-actions bot commented Aug 16, 2024

Coverage report

This PR does not seem to contain any modification to coverable code.

@sydney-runkle sydney-runkle enabled auto-merge (squash) August 16, 2024 15:44
@sydney-runkle sydney-runkle merged commit 929543c into main Aug 16, 2024
57 checks passed
@sydney-runkle sydney-runkle deleted the more-verbose-error-annotations branch August 16, 2024 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes-change Used for changes to existing functionality which don't have a better categorization.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(🐞) no invalid schema error when pattern applied to something that's not str
2 participants