Skip to content

ReturnDict fails with union operator (PEP 584) #8301

Closed
@spookylukey

Description

@spookylukey

Simplest case. Under Python 3.9:

>>> from rest_framework.serializers import Serializer
>>> Serializer().data | {}

Expected output:

{}

Actual behaviour:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/luke/devel/django-rest-framework/rest_framework/utils/serializer_helpers.py", line 17, in __init__
    self.serializer = kwargs.pop('serializer')
KeyError: 'serializer'

I will provide a PR soon.

Checklist

  • I did not raise a discussion, as this is obviously a bug
  • This cannot be dealt with as a third party library. (We prefer new functionality to be in the form of third party libraries where possible.)
  • I have reduced the issue to the simplest possible case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions