Skip to content

Conversation

paulmartin91
Copy link
Contributor

@paulmartin91 paulmartin91 commented May 7, 2024

…oss app

Change Summary

  • For clarity/consistency, added the @classmethod decorator to methods with @model_validate(mode="before"), as described in the docs.

"Before model validators should be class methods. The first argument should be cls (and we also recommend you use @classmethod below @model_validator for proper type checking),"

https://docs.pydantic.dev/latest/concepts/validators/#model-validators

Related issue number

#9407

Checklist

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

Selected Reviewer: @davidhewitt

@paulmartin91
Copy link
Contributor Author

please review

Copy link

codspeed-hq bot commented May 7, 2024

CodSpeed Performance Report

Merging #9410 will not alter performance

Comparing paulmartin91:model-validator-classmethods (a9697ab) with main (07b6473)

Summary

✅ 13 untouched benchmarks

@hramezani hramezani added the relnotes-ignore Omit this PR from the release notes. label May 9, 2024
@davidhewitt davidhewitt merged commit 8925e4f into pydantic:main May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review relnotes-ignore Omit this PR from the release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants