-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 @model_validator
on nested models
#5889
Conversation
|
Deploying with Cloudflare Pages
|
0f73ca7
to
32ee89c
Compare
please review |
@@ -181,7 +181,7 @@ def model_serializer( | |||
*, | |||
mode: Literal['plain', 'wrap'] = 'plain', | |||
json_return_type: _core_schema.JsonReturnTypes | None = None, | |||
) -> Callable[[Any], _decorators.PydanticDescriptorProxy[Any]] | _decorators.PydanticDescriptorProxy[Any]: | |||
) -> Callable[[Any], Any]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a problem that the non-callable return type was removed here? I mean, I'm guessing it's not a problem, but it would it be more careful in some way? Happy to leave like this if preferable just want to make sure it wasn't an oversight.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just pushed a slightly better version. We can get even more granular (e.g. defining a couple of Protocol
s like we do form some of the other validators/serializers) but I don't want to do that in this PR, I'm only changing it because it was causing issues with the test I'm adding here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls can we add (if we don't already have) an example of both @model_validator
and @model_validator(...)
in mypy tests please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise LGTM, tests seem to be failing
@@ -181,7 +181,7 @@ def model_serializer( | |||
*, | |||
mode: Literal['plain', 'wrap'] = 'plain', | |||
json_return_type: _core_schema.JsonReturnTypes | None = None, | |||
) -> Callable[[Any], _decorators.PydanticDescriptorProxy[Any]] | _decorators.PydanticDescriptorProxy[Any]: | |||
) -> Callable[[Any], Any]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls can we add (if we don't already have) an example of both @model_validator
and @model_validator(...)
in mypy tests please.
Added @model_validator to mypy test module
Fixes #5790
Selected Reviewer: @Kludex