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

Improve the types for .data and .validated_data of the Serializers #12

Open
sbdchd opened this issue Jul 6, 2021 · 1 comment
Open

Comments

@sbdchd
Copy link
Owner

sbdchd commented Jul 6, 2021

class FooListSerializer(serializers.ListSerializer):
    ...

reveal_type(FooListSerializer(data).data) # list[Any]
class FooListSerializer(serializers.Serializer):
    ...

reveal_type(FooListSerializer(data, many=True).data) # list[Any]
reveal_type(FooListSerializer(data).data) # dict[str, Any]

need to investigate this more, what happens when passing many=True to a list serializer?

Also need to handle .validated_data as well

rel: https://github.com/encode/django-rest-framework/blob/98e56e0327596db352b35fa3b3dc8355dc9bd030/rest_framework/serializers.py#L117-L122

rel: python/mypy#8330 (comment)
rel: python/mypy#9482

@Viicos
Copy link

Viicos commented Jan 12, 2023

Related: typeddjango#260 (issue), typeddjango#315 (PR)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants