Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.2k
AddValidateFrom
annotation helper#11942
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
PR Change SummaryAdded the
Modified Files
How can I customize these reviews?Check out theHyperlint AI Reviewer docs for more information on how to customize the review. If you just want to ignore it on this PR, you can add the Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add |
Coverage reportClick to see where and how coverage changed
This report was generated bypython-coverage-comment-action |
CodSpeed Performance ReportMerging#11942 willnot alter performanceComparing Summary
|
@timkpaine@ptomecek this is an implementation of an helper that can validate from a type that is natively supported by Pydantic (your use case was using Pydantic models, but TypedDicts/dataclasses etc can also be used). Let me know if this is suitable for you (see my OP for more details on decisions that need to be made before merging). |
Change Summary
Fixes#11682.
Currently, the
instantiation_hook
is required. We could also make it optional and by default populate the arbitrary class by e.g. calling__new__()
. However, by doing so, we need to make some assumptions on thefrom_type
. It can currently be anything (supported by Pydantic: models, dataclasses, typeddicts, etc), but we will have to constrain it to some specific types (perhaps only supporting Pydantic models?) as we will most likely have to assume__dict__
is present to fetch the instance attributes and pass them to__new__()
.Related issue number
Checklist