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

Serializer.validators type does not include Unique... validators #555

Open
mschoettle opened this issue Mar 12, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@mschoettle
Copy link

Bug report

What's wrong

The Serializer.validatorsproperty has the type

Type of "self.validators" is "list[((Any) -> None) | ContextValidator[Any]]"

This is the result of reveal_type(self.validators) on an instance of ModelSerializer. I don't see it explicitly defined in serializers.pyi so I am not sure where exactly it is coming from.

When evaluating the elements of the list against UniqueTogetherValidator mypy reports that the condition always returns False.

None of the Unique... validators are a type that is mentioned above so that is my assumption why that is.

How is that should be

The type for the validators property should include the Unique... validators (at least for ModelSerializer).

System information

  • OS:
  • python version: 3.122
  • django version: 4.2.11
  • mypy version: 1.8.0
  • django-stubs version: 4.2.7
@mschoettle mschoettle added the bug Something isn't working label Mar 12, 2024
@Napparific
Copy link

I have encountered the same issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants