typeddjango / djangorestframework-stubs

PEP-484 stubs for django-rest-framework
MIT License
453 stars 117 forks source link

Fields named as Serializer properties throws assignment error #78

Open lundberg opened 4 years ago

lundberg commented 4 years ago

If a serializer has a field named the same as DRF's Serializer class properties; data, errors and fields, an assignment error will be thrown.

hensg commented 2 years ago

I'm having the same issue but with a field named label Code:


class RiskFieldSerializer(serializers.Serializer):
    id = serializers.CharField()
    label = serializers.CharField()
    status = serializers.CharField()

Error message:

Incompatible types in assignment (expression has type "CharField", base class "Field" defined the type as "Optional[str]")
Brodan commented 8 months ago

just ran into this with a field named label, glad this issue is open or i never would have solved it