From f888bf642b2cdb79bb0bd8e1cb240ec8a4925ecb Mon Sep 17 00:00:00 2001 From: Luca Corti Date: Mon, 4 Dec 2017 18:53:15 +0100 Subject: [PATCH 1/7] Fix NoReverseMatch import for Django >= 2.0 --- rest_framework_json_api/relations.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rest_framework_json_api/relations.py b/rest_framework_json_api/relations.py index b5b36382..4cd5b41a 100644 --- a/rest_framework_json_api/relations.py +++ b/rest_framework_json_api/relations.py @@ -5,7 +5,10 @@ import inflection import six from django.core.exceptions import ImproperlyConfigured -from django.core.urlresolvers import NoReverseMatch +if django.VERSION >= (1, 10): + from django.urls import NoReverseMatch +else: + from django.core.urlresolvers import NoReverseMatch from django.utils.translation import ugettext_lazy as _ from rest_framework.fields import MISSING_ERROR_MESSAGE from rest_framework.relations import MANY_RELATION_KWARGS, PrimaryKeyRelatedField From 7ab702e09791cadfd40dd578543101a189d51dc0 Mon Sep 17 00:00:00 2001 From: Luca Corti Date: Mon, 4 Dec 2017 18:59:07 +0100 Subject: [PATCH 2/7] Missing django import --- rest_framework_json_api/relations.py | 1 + 1 file changed, 1 insertion(+) diff --git a/rest_framework_json_api/relations.py b/rest_framework_json_api/relations.py index 4cd5b41a..028e54a7 100644 --- a/rest_framework_json_api/relations.py +++ b/rest_framework_json_api/relations.py @@ -5,6 +5,7 @@ import inflection import six from django.core.exceptions import ImproperlyConfigured +import django if django.VERSION >= (1, 10): from django.urls import NoReverseMatch else: From c86ae039e6a9e13c6c400b215360877748235ec9 Mon Sep 17 00:00:00 2001 From: Luca Corti Date: Mon, 4 Dec 2017 19:10:47 +0100 Subject: [PATCH 3/7] Move import to the top (flake8) --- rest_framework_json_api/relations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework_json_api/relations.py b/rest_framework_json_api/relations.py index 028e54a7..951fd545 100644 --- a/rest_framework_json_api/relations.py +++ b/rest_framework_json_api/relations.py @@ -1,11 +1,11 @@ import collections +import django import json from collections import OrderedDict import inflection import six from django.core.exceptions import ImproperlyConfigured -import django if django.VERSION >= (1, 10): from django.urls import NoReverseMatch else: From 0359c8252b521d0f7f9e5cb61d5f8623650f7ea4 Mon Sep 17 00:00:00 2001 From: Luca Corti Date: Tue, 5 Dec 2017 01:46:41 +0100 Subject: [PATCH 4/7] Sort imports --- rest_framework_json_api/relations.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rest_framework_json_api/relations.py b/rest_framework_json_api/relations.py index 951fd545..0467b7e3 100644 --- a/rest_framework_json_api/relations.py +++ b/rest_framework_json_api/relations.py @@ -1,10 +1,10 @@ import collections import django -import json -from collections import OrderedDict - import inflection +import json import six + +from collections import OrderedDict from django.core.exceptions import ImproperlyConfigured if django.VERSION >= (1, 10): from django.urls import NoReverseMatch From 6f3608fc5ff9d955e29689a0603e2578c0b1307e Mon Sep 17 00:00:00 2001 From: Luca Corti Date: Tue, 5 Dec 2017 01:51:43 +0100 Subject: [PATCH 5/7] Make flake8 happy --- rest_framework_json_api/relations.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/rest_framework_json_api/relations.py b/rest_framework_json_api/relations.py index 0467b7e3..edc1ab69 100644 --- a/rest_framework_json_api/relations.py +++ b/rest_framework_json_api/relations.py @@ -5,11 +5,6 @@ import six from collections import OrderedDict -from django.core.exceptions import ImproperlyConfigured -if django.VERSION >= (1, 10): - from django.urls import NoReverseMatch -else: - from django.core.urlresolvers import NoReverseMatch from django.utils.translation import ugettext_lazy as _ from rest_framework.fields import MISSING_ERROR_MESSAGE from rest_framework.relations import MANY_RELATION_KWARGS, PrimaryKeyRelatedField @@ -25,6 +20,12 @@ get_resource_type_from_serializer ) +from django.core.exceptions import ImproperlyConfigured +if django.VERSION >= (1, 10): + from django.urls import NoReverseMatch +else: + from django.core.urlresolvers import NoReverseMatch + LINKS_PARAMS = [ 'self_link_view_name', 'related_link_view_name', From 97475f4dc604ef2429769169652c0853301bdbd2 Mon Sep 17 00:00:00 2001 From: Luca Corti Date: Tue, 5 Dec 2017 02:07:05 +0100 Subject: [PATCH 6/7] Make isort happy --- rest_framework_json_api/exceptions.py | 1 - rest_framework_json_api/metadata.py | 1 - rest_framework_json_api/relations.py | 9 ++++----- rest_framework_json_api/renderers.py | 1 - rest_framework_json_api/serializers.py | 1 - rest_framework_json_api/views.py | 1 - 6 files changed, 4 insertions(+), 10 deletions(-) diff --git a/rest_framework_json_api/exceptions.py b/rest_framework_json_api/exceptions.py index 7ffaf256..5773b50e 100644 --- a/rest_framework_json_api/exceptions.py +++ b/rest_framework_json_api/exceptions.py @@ -1,7 +1,6 @@ from django.conf import settings from django.utils.translation import ugettext_lazy as _ from rest_framework import exceptions, status - from rest_framework_json_api import renderers, utils diff --git a/rest_framework_json_api/metadata.py b/rest_framework_json_api/metadata.py index 8306a9dd..b5b68931 100644 --- a/rest_framework_json_api/metadata.py +++ b/rest_framework_json_api/metadata.py @@ -6,7 +6,6 @@ from rest_framework.metadata import SimpleMetadata from rest_framework.settings import api_settings from rest_framework.utils.field_mapping import ClassLookupDict - from rest_framework_json_api.utils import get_related_resource_type diff --git a/rest_framework_json_api/relations.py b/rest_framework_json_api/relations.py index edc1ab69..f213c095 100644 --- a/rest_framework_json_api/relations.py +++ b/rest_framework_json_api/relations.py @@ -1,16 +1,16 @@ import collections +import json +from collections import OrderedDict + import django import inflection -import json import six - -from collections import OrderedDict +from django.core.exceptions import ImproperlyConfigured from django.utils.translation import ugettext_lazy as _ from rest_framework.fields import MISSING_ERROR_MESSAGE from rest_framework.relations import MANY_RELATION_KWARGS, PrimaryKeyRelatedField from rest_framework.reverse import reverse from rest_framework.serializers import Serializer - from rest_framework_json_api.exceptions import Conflict from rest_framework_json_api.utils import ( Hyperlink, @@ -20,7 +20,6 @@ get_resource_type_from_serializer ) -from django.core.exceptions import ImproperlyConfigured if django.VERSION >= (1, 10): from django.urls import NoReverseMatch else: diff --git a/rest_framework_json_api/renderers.py b/rest_framework_json_api/renderers.py index 427fdd9d..b7650379 100644 --- a/rest_framework_json_api/renderers.py +++ b/rest_framework_json_api/renderers.py @@ -10,7 +10,6 @@ from rest_framework import relations, renderers from rest_framework.serializers import BaseSerializer, ListSerializer, Serializer from rest_framework.settings import api_settings - from rest_framework_json_api import utils diff --git a/rest_framework_json_api/serializers.py b/rest_framework_json_api/serializers.py index 06396512..9071d955 100644 --- a/rest_framework_json_api/serializers.py +++ b/rest_framework_json_api/serializers.py @@ -3,7 +3,6 @@ from django.utils.translation import ugettext_lazy as _ from rest_framework.exceptions import ParseError from rest_framework.serializers import * # noqa: F403 - from rest_framework_json_api.exceptions import Conflict from rest_framework_json_api.relations import ResourceRelatedField from rest_framework_json_api.utils import ( diff --git a/rest_framework_json_api/views.py b/rest_framework_json_api/views.py index efb27df7..c99ddad4 100644 --- a/rest_framework_json_api/views.py +++ b/rest_framework_json_api/views.py @@ -8,7 +8,6 @@ from rest_framework.response import Response from rest_framework.reverse import reverse from rest_framework.serializers import Serializer - from rest_framework_json_api.exceptions import Conflict from rest_framework_json_api.serializers import ResourceIdentifierObjectSerializer from rest_framework_json_api.utils import ( From 3541e7212a0e7a892ae301c3d4429204e7205134 Mon Sep 17 00:00:00 2001 From: Luca Corti Date: Tue, 5 Dec 2017 02:16:58 +0100 Subject: [PATCH 7/7] isort behaves differently on travis --- rest_framework_json_api/exceptions.py | 1 + rest_framework_json_api/metadata.py | 1 + rest_framework_json_api/relations.py | 1 + rest_framework_json_api/renderers.py | 1 + rest_framework_json_api/serializers.py | 1 + rest_framework_json_api/views.py | 1 + 6 files changed, 6 insertions(+) diff --git a/rest_framework_json_api/exceptions.py b/rest_framework_json_api/exceptions.py index 5773b50e..7ffaf256 100644 --- a/rest_framework_json_api/exceptions.py +++ b/rest_framework_json_api/exceptions.py @@ -1,6 +1,7 @@ from django.conf import settings from django.utils.translation import ugettext_lazy as _ from rest_framework import exceptions, status + from rest_framework_json_api import renderers, utils diff --git a/rest_framework_json_api/metadata.py b/rest_framework_json_api/metadata.py index b5b68931..8306a9dd 100644 --- a/rest_framework_json_api/metadata.py +++ b/rest_framework_json_api/metadata.py @@ -6,6 +6,7 @@ from rest_framework.metadata import SimpleMetadata from rest_framework.settings import api_settings from rest_framework.utils.field_mapping import ClassLookupDict + from rest_framework_json_api.utils import get_related_resource_type diff --git a/rest_framework_json_api/relations.py b/rest_framework_json_api/relations.py index f213c095..7b37e42a 100644 --- a/rest_framework_json_api/relations.py +++ b/rest_framework_json_api/relations.py @@ -11,6 +11,7 @@ from rest_framework.relations import MANY_RELATION_KWARGS, PrimaryKeyRelatedField from rest_framework.reverse import reverse from rest_framework.serializers import Serializer + from rest_framework_json_api.exceptions import Conflict from rest_framework_json_api.utils import ( Hyperlink, diff --git a/rest_framework_json_api/renderers.py b/rest_framework_json_api/renderers.py index b7650379..427fdd9d 100644 --- a/rest_framework_json_api/renderers.py +++ b/rest_framework_json_api/renderers.py @@ -10,6 +10,7 @@ from rest_framework import relations, renderers from rest_framework.serializers import BaseSerializer, ListSerializer, Serializer from rest_framework.settings import api_settings + from rest_framework_json_api import utils diff --git a/rest_framework_json_api/serializers.py b/rest_framework_json_api/serializers.py index 9071d955..06396512 100644 --- a/rest_framework_json_api/serializers.py +++ b/rest_framework_json_api/serializers.py @@ -3,6 +3,7 @@ from django.utils.translation import ugettext_lazy as _ from rest_framework.exceptions import ParseError from rest_framework.serializers import * # noqa: F403 + from rest_framework_json_api.exceptions import Conflict from rest_framework_json_api.relations import ResourceRelatedField from rest_framework_json_api.utils import ( diff --git a/rest_framework_json_api/views.py b/rest_framework_json_api/views.py index c99ddad4..efb27df7 100644 --- a/rest_framework_json_api/views.py +++ b/rest_framework_json_api/views.py @@ -8,6 +8,7 @@ from rest_framework.response import Response from rest_framework.reverse import reverse from rest_framework.serializers import Serializer + from rest_framework_json_api.exceptions import Conflict from rest_framework_json_api.serializers import ResourceIdentifierObjectSerializer from rest_framework_json_api.utils import (