Skip to content

Commit

Permalink
Switch to isort and clean up imports
Browse files Browse the repository at this point in the history
  • Loading branch information
jleclanche committed Sep 15, 2017
1 parent 47dd70f commit 2129f32
Show file tree
Hide file tree
Showing 29 changed files with 77 additions and 76 deletions.
11 changes: 8 additions & 3 deletions docs/conf.py
Expand Up @@ -11,7 +11,14 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os, re
import os
import re
import sys

import django

import oauth2_provider


# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand All @@ -22,10 +29,8 @@

os.environ["DJANGO_SETTINGS_MODULE"] = "tests.settings"

import django
django.setup()

import oauth2_provider

# -- General configuration -----------------------------------------------------

Expand Down
6 changes: 2 additions & 4 deletions oauth2_provider/admin.py
@@ -1,10 +1,8 @@
from django.contrib import admin

from .models import (
get_access_token_model,
get_application_model,
get_grant_model,
get_refresh_token_model,
get_access_token_model, get_application_model,
get_grant_model, get_refresh_token_model
)


Expand Down
1 change: 1 addition & 0 deletions oauth2_provider/compat.py
Expand Up @@ -5,6 +5,7 @@
# flake8: noqa
from __future__ import unicode_literals


# urlparse in python3 has been renamed to urllib.parse
try:
from urlparse import parse_qs, parse_qsl, urlparse, urlsplit, urlunparse, urlunsplit
Expand Down
2 changes: 1 addition & 1 deletion oauth2_provider/contrib/rest_framework/permissions.py
Expand Up @@ -3,8 +3,8 @@
from django.core.exceptions import ImproperlyConfigured
from rest_framework.permissions import BasePermission, IsAuthenticated

from .authentication import OAuth2Authentication
from ...settings import oauth2_settings
from .authentication import OAuth2Authentication


log = logging.getLogger("oauth2_provider")
Expand Down
3 changes: 1 addition & 2 deletions oauth2_provider/generators.py
@@ -1,5 +1,4 @@
from __future__ import absolute_import
from __future__ import unicode_literals
from __future__ import absolute_import, unicode_literals

from oauthlib.common import generate_client_id as oauthlib_generate_client_id
from oauthlib.common import UNICODE_ASCII_CHARACTER_SET
Expand Down
7 changes: 2 additions & 5 deletions oauth2_provider/oauth2_validators.py
Expand Up @@ -17,11 +17,8 @@
from .compat import unquote_plus
from .exceptions import FatalClientError
from .models import (
AbstractApplication,
get_access_token_model,
get_application_model,
get_grant_model,
get_refresh_token_model,
AbstractApplication, get_access_token_model,
get_application_model, get_grant_model, get_refresh_token_model
)
from .scopes import get_scopes_backend
from .settings import oauth2_settings
Expand Down
3 changes: 1 addition & 2 deletions oauth2_provider/scopes.py
@@ -1,5 +1,4 @@
from __future__ import absolute_import
from __future__ import unicode_literals
from __future__ import absolute_import, unicode_literals

from .settings import oauth2_settings

Expand Down
1 change: 1 addition & 0 deletions oauth2_provider/signals.py
@@ -1,3 +1,4 @@
from django.dispatch import Signal


app_authorized = Signal(providing_args=['request', 'token'])
4 changes: 3 additions & 1 deletion oauth2_provider/views/application.py
@@ -1,7 +1,9 @@
from django.contrib.auth.mixins import LoginRequiredMixin
from django.forms.models import modelform_factory
from django.urls import reverse_lazy
from django.views.generic import CreateView, DeleteView, DetailView, ListView, UpdateView
from django.views.generic import (
CreateView, DeleteView, DetailView, ListView, UpdateView
)

from ..models import get_application_model

Expand Down
4 changes: 2 additions & 2 deletions oauth2_provider/views/base.py
Expand Up @@ -9,14 +9,14 @@
from django.views.decorators.debug import sensitive_post_parameters
from django.views.generic import FormView, View

from ..signals import app_authorized
from .mixins import OAuthLibMixin
from ..exceptions import OAuthToolkitError
from ..forms import AllowForm
from ..http import HttpResponseUriRedirect
from ..models import get_access_token_model, get_application_model
from ..scopes import get_scopes_backend
from ..settings import oauth2_settings
from ..signals import app_authorized
from .mixins import OAuthLibMixin


log = logging.getLogger("oauth2_provider")
Expand Down
4 changes: 3 additions & 1 deletion oauth2_provider/views/generic.py
@@ -1,7 +1,9 @@
from django.views.generic import View

from .mixins import ProtectedResourceMixin, ReadWriteScopedResourceMixin, ScopedResourceMixin
from ..settings import oauth2_settings
from .mixins import (
ProtectedResourceMixin, ReadWriteScopedResourceMixin, ScopedResourceMixin
)


class ProtectedResourceView(ProtectedResourceMixin, View):
Expand Down
5 changes: 1 addition & 4 deletions tests/test_auth_backends.py
Expand Up @@ -7,10 +7,7 @@

from oauth2_provider.backends import OAuth2Backend
from oauth2_provider.middleware import OAuth2TokenMiddleware
from oauth2_provider.models import (
get_access_token_model,
get_application_model,
)
from oauth2_provider.models import get_access_token_model, get_application_model


UserModel = get_user_model()
Expand Down
7 changes: 3 additions & 4 deletions tests/test_authorization_code.py
Expand Up @@ -12,13 +12,12 @@

from oauth2_provider.compat import parse_qs, urlencode, urlparse
from oauth2_provider.models import (
get_access_token_model,
get_application_model,
get_grant_model,
get_refresh_token_model,
get_access_token_model, get_application_model,
get_grant_model, get_refresh_token_model
)
from oauth2_provider.settings import oauth2_settings
from oauth2_provider.views import ProtectedResourceView

from .utils import get_basic_auth_header


Expand Down
6 changes: 2 additions & 4 deletions tests/test_client_credential.py
Expand Up @@ -9,15 +9,13 @@
from oauthlib.oauth2 import BackendApplicationServer

from oauth2_provider.compat import quote_plus
from oauth2_provider.models import (
get_access_token_model,
get_application_model,
)
from oauth2_provider.models import get_access_token_model, get_application_model
from oauth2_provider.oauth2_backends import OAuthLibCore
from oauth2_provider.oauth2_validators import OAuth2Validator
from oauth2_provider.settings import oauth2_settings
from oauth2_provider.views import ProtectedResourceView
from oauth2_provider.views.mixins import OAuthLibMixin

from .utils import get_basic_auth_header


Expand Down
5 changes: 1 addition & 4 deletions tests/test_decorators.py
Expand Up @@ -5,10 +5,7 @@
from django.utils import timezone

from oauth2_provider.decorators import protected_resource, rw_protected_resource
from oauth2_provider.models import (
get_access_token_model,
get_application_model,
)
from oauth2_provider.models import get_access_token_model, get_application_model
from oauth2_provider.settings import oauth2_settings


Expand Down
3 changes: 2 additions & 1 deletion tests/test_introspection_auth.py
Expand Up @@ -6,7 +6,7 @@
from django.conf.urls import include, url
from django.contrib.auth import get_user_model
from django.http import HttpResponse
from django.test import override_settings, TestCase
from django.test import TestCase, override_settings
from django.utils import timezone
from oauthlib.common import Request

Expand All @@ -15,6 +15,7 @@
from oauth2_provider.settings import oauth2_settings
from oauth2_provider.views import ScopedProtectedResourceView


try:
from unittest import mock
except ImportError:
Expand Down
1 change: 1 addition & 0 deletions tests/test_introspection_view.py
Expand Up @@ -11,6 +11,7 @@
from oauth2_provider.models import get_access_token_model, get_application_model
from oauth2_provider.settings import oauth2_settings


Application = get_application_model()
AccessToken = get_access_token_model()
UserModel = get_user_model()
Expand Down
5 changes: 3 additions & 2 deletions tests/test_mixins.py
Expand Up @@ -3,12 +3,13 @@
from django.core.exceptions import ImproperlyConfigured
from django.test import RequestFactory, TestCase
from django.views.generic import View

from oauthlib.oauth2 import Server

from oauth2_provider.oauth2_backends import OAuthLibCore
from oauth2_provider.oauth2_validators import OAuth2Validator
from oauth2_provider.views.mixins import OAuthLibMixin, ProtectedResourceMixin, ScopedResourceMixin
from oauth2_provider.views.mixins import (
OAuthLibMixin, ProtectedResourceMixin, ScopedResourceMixin
)


class BaseTest(TestCase):
Expand Down
7 changes: 3 additions & 4 deletions tests/test_models.py
Expand Up @@ -7,13 +7,12 @@
from django.utils import timezone

from oauth2_provider.models import (
get_access_token_model,
get_application_model,
get_grant_model,
get_refresh_token_model,
get_access_token_model, get_application_model,
get_grant_model, get_refresh_token_model
)
from oauth2_provider.settings import oauth2_settings


Application = get_application_model()
Grant = get_grant_model()
AccessToken = get_access_token_model()
Expand Down
9 changes: 6 additions & 3 deletions tests/test_oauth2_backends.py
@@ -1,14 +1,17 @@
import json

from django.test import RequestFactory, TestCase

from oauth2_provider.backends import get_oauthlib_core
from oauth2_provider.oauth2_backends import JSONOAuthLibCore, OAuthLibCore


try:
from unittest import mock
except ImportError:
import mock

from django.test import RequestFactory, TestCase

from oauth2_provider.backends import get_oauthlib_core
from oauth2_provider.oauth2_backends import JSONOAuthLibCore, OAuthLibCore


class TestOAuthLibCoreBackend(TestCase):
Expand Down
15 changes: 7 additions & 8 deletions tests/test_oauth2_validators.py
@@ -1,24 +1,23 @@
import datetime

try:
from unittest import mock
except ImportError:
import mock

from django.contrib.auth import get_user_model
from django.test import TransactionTestCase
from django.utils import timezone
from oauthlib.common import Request

from oauth2_provider.exceptions import FatalClientError
from oauth2_provider.models import (
get_access_token_model,
get_application_model,
get_refresh_token_model,
get_access_token_model, get_application_model, get_refresh_token_model
)
from oauth2_provider.oauth2_validators import OAuth2Validator


try:
from unittest import mock
except ImportError:
import mock


UserModel = get_user_model()
Application = get_application_model()
AccessToken = get_access_token_model()
Expand Down
1 change: 1 addition & 0 deletions tests/test_password.py
Expand Up @@ -9,6 +9,7 @@
from oauth2_provider.models import get_application_model
from oauth2_provider.settings import oauth2_settings
from oauth2_provider.views import ProtectedResourceView

from .utils import get_basic_auth_header


Expand Down
5 changes: 1 addition & 4 deletions tests/test_rest_framework.py
Expand Up @@ -8,10 +8,7 @@
from django.test.utils import override_settings
from django.utils import timezone

from oauth2_provider.models import (
get_access_token_model,
get_application_model,
)
from oauth2_provider.models import get_access_token_model, get_application_model
from oauth2_provider.settings import oauth2_settings


Expand Down
8 changes: 4 additions & 4 deletions tests/test_scopes.py
Expand Up @@ -9,12 +9,12 @@

from oauth2_provider.compat import parse_qs, urlparse
from oauth2_provider.models import (
get_access_token_model,
get_application_model,
get_grant_model,
get_access_token_model, get_application_model, get_grant_model
)
from oauth2_provider.settings import oauth2_settings
from oauth2_provider.views import ReadWriteScopedResourceView, ScopedProtectedResourceView
from oauth2_provider.views import (
ReadWriteScopedResourceView, ScopedProtectedResourceView
)

from .utils import get_basic_auth_header

Expand Down
3 changes: 1 addition & 2 deletions tests/test_scopes_backend.py
@@ -1,5 +1,4 @@
from __future__ import absolute_import
from __future__ import unicode_literals
from __future__ import absolute_import, unicode_literals

from oauth2_provider.scopes import SettingsScopes

Expand Down
4 changes: 1 addition & 3 deletions tests/test_token_revocation.py
Expand Up @@ -9,9 +9,7 @@

from oauth2_provider.compat import urlencode
from oauth2_provider.models import (
get_access_token_model,
get_application_model,
get_refresh_token_model,
get_access_token_model, get_application_model, get_refresh_token_model
)
from oauth2_provider.settings import oauth2_settings

Expand Down
5 changes: 1 addition & 4 deletions tests/test_token_view.py
Expand Up @@ -7,10 +7,7 @@
from django.urls import reverse
from django.utils import timezone

from oauth2_provider.models import (
get_access_token_model,
get_application_model,
)
from oauth2_provider.models import get_access_token_model, get_application_model


Application = get_application_model()
Expand Down
1 change: 1 addition & 0 deletions tests/urls.py
@@ -1,6 +1,7 @@
from django.conf.urls import include, url
from django.contrib import admin


admin.autodiscover()


Expand Down

0 comments on commit 2129f32

Please sign in to comment.