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

Fix mypy plugin handling of @model_validator(mode="after") #6753

Merged
merged 1 commit into from Jul 19, 2023

Conversation

ljodal
Copy link
Contributor

@ljodal ljodal commented Jul 19, 2023

Change Summary

The mypy plugin would convert any method decorated with @model_validator to a classmethod, but that's wrong for the after mode, where it expects a normal method.

Related issue number

Fix #6709

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

Selected Reviewer: @dmontagu

The mypy plugin would convert any method decorated with @model_validator
to a classmethod, but that's wrong for the after mode, where it expects
a normal method.

Fixes pydantic#6709
@ljodal
Copy link
Contributor Author

ljodal commented Jul 19, 2023

please review

@dmontagu
Copy link
Contributor

dmontagu commented Jul 19, 2023

This is great work. Thank you for the contribution!

@dmontagu dmontagu merged commit b60aaa4 into pydantic:main Jul 19, 2023
47 checks passed
@ljodal ljodal deleted the fix-mypy-model-validator-after branch July 19, 2023 22:02
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.

Mypy Plugin causes errors when using model_validator
2 participants