From 7a698e80c21264e784d3a91b6d9589c348b43a9b Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Mon, 7 Apr 2025 19:14:01 +0100 Subject: [PATCH] Remove condition for unsupported Python versions --- rest_framework/utils/serializer_helpers.py | 28 ++++++++++------------ 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/rest_framework/utils/serializer_helpers.py b/rest_framework/utils/serializer_helpers.py index 0e59aa66a..e6bd84f30 100644 --- a/rest_framework/utils/serializer_helpers.py +++ b/rest_framework/utils/serializer_helpers.py @@ -1,5 +1,4 @@ import contextlib -import sys from collections.abc import Mapping, MutableMapping from django.utils.encoding import force_str @@ -29,21 +28,20 @@ class ReturnDict(dict): # but preserve the raw data. return (dict, (dict(self),)) - if sys.version_info >= (3, 9): - # These are basically copied from OrderedDict, with `serializer` added. - def __or__(self, other): - if not isinstance(other, dict): - return NotImplemented - new = self.__class__(self, serializer=self.serializer) - new.update(other) - return new + # These are basically copied from OrderedDict, with `serializer` added. + def __or__(self, other): + if not isinstance(other, dict): + return NotImplemented + new = self.__class__(self, serializer=self.serializer) + new.update(other) + return new - def __ror__(self, other): - if not isinstance(other, dict): - return NotImplemented - new = self.__class__(other, serializer=self.serializer) - new.update(self) - return new + def __ror__(self, other): + if not isinstance(other, dict): + return NotImplemented + new = self.__class__(other, serializer=self.serializer) + new.update(self) + return new class ReturnList(list):