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 · 6 comments
Open

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

mschoettle opened this issue Mar 12, 2024 · 6 comments
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!

@Limsunoh
Copy link

@mschoettle I'm a junior developer, can I take a look at this?

@mschoettle
Copy link
Author

@Limsunoh Yes, of course

@Limsunoh
Copy link

@mschoettle I've made code fixes and test code, can I put them together in a PR? But I'm not sure if this is correct

@Limsunoh
Copy link

image
@mschoettle I also created a separate test code file this way, do I need to upload the test code as well? Or should I upload it without the test files?

@Napparific
Copy link

@Limsunoh Most open source repositories (this one included) will have a contribution guide you can use to understand what the requirements in a PR are

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

3 participants