Skip to content

fix: type-error on model_validator in wrap mode#7496

Merged
davidhewitt merged 2 commits intopydantic:mainfrom
pmmmwh:patch-1
Sep 19, 2023
Merged

fix: type-error on model_validator in wrap mode#7496
davidhewitt merged 2 commits intopydantic:mainfrom
pmmmwh:patch-1

Conversation

@pmmmwh
Copy link
Copy Markdown
Contributor

@pmmmwh pmmmwh commented Sep 19, 2023

Change Summary

Since #7154, ModelWrapValidator is generic, and if reportUnknownVariableType is enabled in Pyright the import will be a type-error. I think it was an oversight to not add the type-parameter here as the other generic model validator type (ModelAfterValidator) consumes the type-parameter - and adding it indeed fixes the issue.

I think this doesn't need a new test as it's purely a type-level change.

Related issue number

Prior PR - #7154

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: @davidhewitt

Since #7154, `ModelWrapValidator` is generic, and if `reportUnknownVariableType` is enabled in Pyright the import will be a type-error. I think it was an oversight to not add the type-parameter here as the other generic model validator type (`ModelAfterValidator`) consumes the type-parameter - and adding it indeed fixes the issue.
@pmmmwh
Copy link
Copy Markdown
Contributor Author

pmmmwh commented Sep 19, 2023

please review

Copy link
Copy Markdown
Collaborator

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Agreed, thanks!

@davidhewitt davidhewitt merged commit f468466 into pydantic:main Sep 19, 2023
@pmmmwh pmmmwh deleted the patch-1 branch September 20, 2023 13:31
@davidhewitt davidhewitt added the relnotes-fix Used for bugfixes. label Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants