Alias and use compat version of collections.abc.MutableMapping

Since the MutableMapping class will no longer be available to import
directly from the collections module in Python 3.8, we should create an
alias for it in the compat module and use that instead.
This commit is contained in:
Charlie Hornsby 2018-10-20 18:29:59 +03:00
parent 339dfab5f5
commit 319071d319
2 changed files with 4 additions and 5 deletions

View File

@ -12,10 +12,10 @@ from django.views.generic import View
try: try:
# Python 3 # Python 3
from collections.abc import Mapping # noqa from collections.abc import Mapping, MutableMapping # noqa
except ImportError: except ImportError:
# Python 2.7 # Python 2.7
from collections import Mapping # noqa from collections import Mapping, MutableMapping # noqa
try: try:
# Python 3 # Python 3

View File

@ -1,11 +1,10 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import collections
from collections import OrderedDict from collections import OrderedDict
from django.utils.encoding import force_text from django.utils.encoding import force_text
from rest_framework.compat import unicode_to_repr from rest_framework.compat import MutableMapping, unicode_to_repr
from rest_framework.utils import json from rest_framework.utils import json
@ -130,7 +129,7 @@ class NestedBoundField(BoundField):
return self.__class__(self._field, values, self.errors, self._prefix) return self.__class__(self._field, values, self.errors, self._prefix)
class BindingDict(collections.MutableMapping): class BindingDict(MutableMapping):
""" """
This dict-like object is used to store fields on a serializer. This dict-like object is used to store fields on a serializer.