Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Draft
Viicos wants to merge1 commit intomain
base:main
Choose a base branch
Loading
fromvalidate-from
Draft

AddValidateFrom annotation helper#11942

Viicos wants to merge1 commit intomainfromvalidate-from

Conversation

Viicos
Copy link
Member

Change Summary

Fixes#11682.

Currently, theinstantiation_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

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review,please add a comment including the phrase "please review" to assign reviewers

@github-actionsgithub-actionsbot added the relnotes-fixUsed for bugfixes. labelJun 2, 2025
@hyperlint-aiHyperlint AI
Copy link
Contributor

PR Change Summary

Added theValidateFrom annotation helper to enhance type validation in Pydantic.

  • Introduced theValidateFrom annotation helper for custom type validation.
  • Provided an example demonstrating the usage ofValidateFrom with a custom class.
  • Updated documentation to reflect the new validation capabilities.

Modified Files

  • docs/concepts/validators.md

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 thehyperlint-ignore label to the PR. Future changes won't trigger a Hyperlint review.

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 addhyperlint-ignore to the PR to ignore the link check for this PR.

@github-actionsGitHub Actions
Copy link
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  pydantic
  functional_validators.py
Project Total 

This report was generated bypython-coverage-comment-action

@codspeed-hqCodSpeed HQ
Copy link

CodSpeed Performance Report

Merging#11942 willnot alter performance

Comparingvalidate-from (ffab3d8) withmain (88c75cd)

Summary

✅ 46 untouched benchmarks

@Viicos
Copy link
MemberAuthor

@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).

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
relnotes-fixUsed for bugfixes.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2.11 Regression - Nested annotation references lead to model never being fully buildable
1 participant
@Viicos

[8]ページ先頭

©2009-2025 Movatter.jp