Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve initialization hooks example #6822

Merged
merged 2 commits into from Jul 24, 2023

Conversation

hramezani
Copy link
Member

@hramezani hramezani commented Jul 24, 2023

Closes #6806

Selected Reviewer: @samuelcolvin

@cloudflare-pages
Copy link

cloudflare-pages bot commented Jul 24, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: b965ca1
Status: ✅  Deploy successful!
Preview URL: https://c2808411.pydantic-docs2.pages.dev
Branch Preview URL: https://improve-initialization-hooks.pydantic-docs2.pages.dev

View logs

@hramezani hramezani force-pushed the improve-initialization-hooks-example branch from e9e3fc1 to 15f4a1f Compare July 24, 2023 12:08
@hramezani
Copy link
Member Author

Please review

Copy link
Member

@Kludex Kludex left a comment

Choose a reason for hiding this comment

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

Do we mention that `post_init`` comes in the "middle" between the validators somewhere?

@hramezani hramezani force-pushed the improve-initialization-hooks-example branch from b014f3d to 48906a9 Compare July 24, 2023 14:13
@hramezani
Copy link
Member Author

Do we mention that `post_init`` comes in the "middle" between the validators somewhere?

There is a line after this code block that says

Do we mention that `post_init`` comes in the "middle" between the validators somewhere?

I've change it to make it more clear

Comment on lines 404 to 409
* Before model validator.
* Before field validator.
* After field validator.
* Field type validators. e.g. validation for types like `int`, `str`, ... .
* `__post_init__`.
* After model validator.
Copy link
Member

Choose a reason for hiding this comment

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

I think model_validator(mode='before'), field_validator(mode='before'), etc. notation looks better. 👀

Also, I think we call the "Field type validators" differently in the rest of the documentation? 🤔 Inner validator? I'm not sure...

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, look better.
I changed them.

@hramezani hramezani enabled auto-merge (squash) July 24, 2023 15:50
@hramezani hramezani merged commit 2c44911 into main Jul 24, 2023
47 checks passed
@hramezani hramezani deleted the improve-initialization-hooks-example branch July 24, 2023 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

__post_init__ executes before @model_validator(mode="after")
3 participants