From ff86f09f74a0f60b657576abc8cf805c308a3974 Mon Sep 17 00:00:00 2001
From: Jon Dufresne <jon.dufresne@gmail.com>
Date: Tue, 30 Apr 2019 22:44:33 -0700
Subject: [PATCH] Remove unnecessary compatibility shims from
 rest_framework/compat.py (#6631)

For Python 3, collections.abc.Mapping and collections.abc.MutableMapping
are always available from the stdlib.
---
 rest_framework/compat.py                   | 1 -
 rest_framework/fields.py                   | 3 ++-
 rest_framework/serializers.py              | 3 ++-
 rest_framework/utils/serializer_helpers.py | 2 +-
 tests/test_renderers.py                    | 3 ++-
 tests/test_serializer.py                   | 2 +-
 6 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/rest_framework/compat.py b/rest_framework/compat.py
index aad44e342..3068665a8 100644
--- a/rest_framework/compat.py
+++ b/rest_framework/compat.py
@@ -3,7 +3,6 @@ The `compat` module provides support for backwards compatibility with older
 versions of Django/Python, and compatibility wrappers around optional packages.
 """
 import sys
-from collections.abc import Mapping, MutableMapping  # noqa
 
 from django.conf import settings
 from django.core import validators
diff --git a/rest_framework/fields.py b/rest_framework/fields.py
index ad9611e05..1cffdcc2d 100644
--- a/rest_framework/fields.py
+++ b/rest_framework/fields.py
@@ -6,6 +6,7 @@ import inspect
 import re
 import uuid
 from collections import OrderedDict
+from collections.abc import Mapping
 
 from django.conf import settings
 from django.core.exceptions import ObjectDoesNotExist
@@ -30,7 +31,7 @@ from pytz.exceptions import InvalidTimeError
 
 from rest_framework import ISO_8601
 from rest_framework.compat import (
-    Mapping, MaxLengthValidator, MaxValueValidator, MinLengthValidator,
+    MaxLengthValidator, MaxValueValidator, MinLengthValidator,
     MinValueValidator, ProhibitNullCharactersValidator
 )
 from rest_framework.exceptions import ErrorDetail, ValidationError
diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py
index 90b31e068..651ca81cf 100644
--- a/rest_framework/serializers.py
+++ b/rest_framework/serializers.py
@@ -14,6 +14,7 @@ import copy
 import inspect
 import traceback
 from collections import OrderedDict
+from collections.abc import Mapping
 
 from django.core.exceptions import ImproperlyConfigured
 from django.core.exceptions import ValidationError as DjangoValidationError
@@ -25,7 +26,7 @@ from django.utils import timezone
 from django.utils.functional import cached_property
 from django.utils.translation import ugettext_lazy as _
 
-from rest_framework.compat import Mapping, postgres_fields
+from rest_framework.compat import postgres_fields
 from rest_framework.exceptions import ErrorDetail, ValidationError
 from rest_framework.fields import get_error_detail, set_value
 from rest_framework.settings import api_settings
diff --git a/rest_framework/utils/serializer_helpers.py b/rest_framework/utils/serializer_helpers.py
index 8709352f1..80aea27d3 100644
--- a/rest_framework/utils/serializer_helpers.py
+++ b/rest_framework/utils/serializer_helpers.py
@@ -1,8 +1,8 @@
 from collections import OrderedDict
+from collections.abc import MutableMapping
 
 from django.utils.encoding import force_text
 
-from rest_framework.compat import MutableMapping
 from rest_framework.utils import json
 
 
diff --git a/tests/test_renderers.py b/tests/test_renderers.py
index 54d1cb231..bc775547d 100644
--- a/tests/test_renderers.py
+++ b/tests/test_renderers.py
@@ -1,5 +1,6 @@
 import re
 from collections import OrderedDict
+from collections.abc import MutableMapping
 
 import pytest
 from django.conf.urls import include, url
@@ -12,7 +13,7 @@ from django.utils.safestring import SafeText
 from django.utils.translation import ugettext_lazy as _
 
 from rest_framework import permissions, serializers, status
-from rest_framework.compat import MutableMapping, coreapi
+from rest_framework.compat import coreapi
 from rest_framework.decorators import action
 from rest_framework.renderers import (
     AdminRenderer, BaseRenderer, BrowsableAPIRenderer, DocumentationRenderer,
diff --git a/tests/test_serializer.py b/tests/test_serializer.py
index 8f4d9bf63..33cc0b60c 100644
--- a/tests/test_serializer.py
+++ b/tests/test_serializer.py
@@ -2,12 +2,12 @@ import inspect
 import pickle
 import re
 from collections import ChainMap
+from collections.abc import Mapping
 
 import pytest
 from django.db import models
 
 from rest_framework import exceptions, fields, relations, serializers
-from rest_framework.compat import Mapping
 from rest_framework.fields import Field
 
 from .models import (