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

docs: More specificmodel_post_init explanation#10453

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

Merged
sydney-runkle merged 1 commit intopydantic:mainfromsantibreo:patch-1
Sep 26, 2024

Conversation

santibreo
Copy link
Contributor

I want to make a small but specific change to the documentation. I find the library great, but I feel a little confused when I use field validators, model validators, andmodel_post_init all at once. To illustrate this, I createdthis gist.

Because there are so many ways to hook into model instantiation, I would like to clarify their order of precedence.

sydney-runkle reacted with thumbs up emoji
@github-actionsgithub-actionsbot added the relnotes-fixUsed for bugfixes. labelSep 20, 2024
@codspeed-hqCodSpeed HQ
Copy link

CodSpeed Performance Report

Merging#10453 willnot alter performance

Comparingsantibreo:patch-1 (5c253e0) withmain (e301d4a)

Summary

✅ 38 untouched benchmarks

@github-actionsGitHub Actions
Copy link
Contributor

Coverage report

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

@sydney-runkle
Copy link
Contributor

Hi! Thanks for the contribution.

I believe this takes place afterall validation, so perhaps it'd be better to specify that instead? Not narrow down to just field validators?

@santibreo
Copy link
ContributorAuthor

santibreo commentedSep 21, 2024
edited
Loading

Hi, thanks for your comment. As far as I discovered (you can check in the gist) themodel_validator(..., mode='after')takes place aftermodel_post_init. That was causing my confusion. I think it is a natural guess:__init__ ➡️ model validation before ➡️ field validation before ➡️ field validation after ➡️ model validation after ➡️model post init. But the end is: ... ➡️model_post_init ➡️ model validation after.

sydney-runkle reacted with thumbs up emoji

@sydney-runkle
Copy link
Contributor

@santibreo,

Thanks for following up! Ah yes, now I recall, we inject different functional validators at different points in the core schema.

Perhaps it's best to document this pattern somewhere explicitly (inconcepts/validators) maybe, rather than just a docstring update here?

@sydney-runkle
Copy link
Contributor

Also, happy to accept this PR and I can work on that docs PR. Lmk if you're still interested in more docs updates here!

@santibreo
Copy link
ContributorAuthor

Hi!. I agree it would be better to include a more in-depth explanation inconcepts/validators. I think you can keep using this PR or you can close it linked to the new one. Either case works for me.
Thank you!

sydney-runkle reacted with thumbs up emoji

@sydney-runklesydney-runkle added documentation and removed relnotes-fixUsed for bugfixes. labelsSep 26, 2024
@sydney-runkle
Copy link
Contributor

Going to go ahead and merge as is, I think my lingering concerns can be addressed with#8277

santibreo reacted with thumbs up emoji

@sydney-runklesydney-runkle merged commit643ea79 intopydantic:mainSep 26, 2024
62 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@sydney-runklesydney-runklesydney-runkle approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@santibreo@sydney-runkle

[8]ページ先頭

©2009-2025 Movatter.jp