Skip to content

Support serializer field with name "fields" #12

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

Closed
kalekseev opened this issue Mar 18, 2019 · 3 comments
Closed

Support serializer field with name "fields" #12

kalekseev opened this issue Mar 18, 2019 · 3 comments

Comments

@kalekseev
Copy link
Contributor

Consider the case:

 class FieldsSerializer(serializers.Serializer):
     ...
 
 
 class OtherSerializer(serializers.Serializer):
    fields = FieldsSerializer()

Mypy will complain with: error: Incompatible types in assignment (expression has type "FieldsSerializer", base class "Serializer" defined the type as "Dict[str, Field]")

@MarcinWieczorek
Copy link
Contributor

You're trying to shadow Serializer's property fields, I think you really shouldn't do that, internals might be relying on that

@MarcinWieczorek
Copy link
Contributor

imho it's a wontfix and should be closed.

@sobolevn
Copy link
Member

I agree. fields is defined in Serializer. The best practice is not to override names like that.

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

No branches or pull requests

3 participants