Skip to content

Commit

Permalink
Merge pull request #155 from sphrak/feature/adds-isort
Browse files Browse the repository at this point in the history
fixes #154 -- adds isort
  • Loading branch information
belugame authored Jan 10, 2019
2 parents a99cca4 + 0ef8da1 commit 1e2adba
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 32 deletions.
7 changes: 7 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[settings]
combine_as_imports = true
default_section = THIRDPARTY
include_trailing_comma = true
known_first_party = knox
multi_line_output = 5
not_skip = __init__.py
1 change: 1 addition & 0 deletions knox/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from django.contrib import admin

from knox import models


Expand Down
8 changes: 3 additions & 5 deletions knox/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ def compare_digest(a, b):

import binascii

from django.utils.translation import ugettext_lazy as _
from django.utils import timezone
from django.contrib.auth import get_user_model

from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
from rest_framework import exceptions
from rest_framework.authentication import (
BaseAuthentication,
get_authorization_header
BaseAuthentication, get_authorization_header,
)

from knox.crypto import hash_token
Expand Down
4 changes: 2 additions & 2 deletions knox/crypto.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import binascii
from os import urandom as generate_bytes

from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from os import urandom as generate_bytes

from knox.settings import knox_settings, CONSTANTS
from knox.settings import CONSTANTS, knox_settings

sha = knox_settings.SECURE_HASH_ALGORITHM

Expand Down
2 changes: 1 addition & 1 deletion knox/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion knox/migrations/0002_auto_20150916_1425.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion knox/migrations/0003_auto_20150916_1526.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down
1 change: 0 additions & 1 deletion knox/serializers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.contrib.auth import get_user_model

from rest_framework import serializers

User = get_user_model()
Expand Down
1 change: 1 addition & 0 deletions knox/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from datetime import timedelta

from django.conf import settings
from django.test.signals import setting_changed
from rest_framework.settings import APISettings
Expand Down
1 change: 0 additions & 1 deletion knox/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.contrib.auth.signals import user_logged_in, user_logged_out
from django.utils import timezone

from rest_framework import status
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
Expand Down
3 changes: 2 additions & 1 deletion knox_project/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from knox.auth import TokenAuthentication
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView

from knox.auth import TokenAuthentication


class RootView(APIView):
authentication_classes = (TokenAuthentication,)
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Always prefer setuptools over distutils
from setuptools import setup, find_packages
# To use a consistent encoding
from codecs import open
from os import path

from setuptools import find_packages, setup

here = path.abspath(path.dirname(__file__))

# Get the long description from the relevant file
Expand Down
23 changes: 9 additions & 14 deletions tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import base64
from datetime import datetime, timedelta

from django.utils.six.moves import reload_module
from django.contrib.auth import get_user_model
from django.test import override_settings
from django.utils.six.moves import reload_module
from freezegun import freeze_time
from rest_framework.test import APIRequestFactory, APITestCase as TestCase

from knox import auth, views
from knox.auth import TokenAuthentication
from knox.models import AuthToken
from knox.serializers import UserSerializer
from knox.settings import CONSTANTS, knox_settings
from knox.signals import token_expired

try:
# For django >= 2.0
Expand All @@ -13,19 +21,6 @@
# For django < 2.0
from django.conf.urls import reverse

from freezegun import freeze_time

from rest_framework.test import (
APIRequestFactory,
APITestCase as TestCase
)

from knox.auth import TokenAuthentication
from knox.signals import token_expired
from knox.models import AuthToken
from knox.settings import CONSTANTS, knox_settings
from knox.serializers import UserSerializer

User = get_user_model()
root_url = reverse('api-root')

Expand Down
19 changes: 15 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
[tox]
envlist =
flake8,
py{27,34,35,36}-django111,
py{34,35,36}-django20,
py{35,36,37}-django21,
isort
flake8,
py{27,34,35,36}-django111,
py{34,35,36}-django20,
py{35,36,37}-django21,

[testenv:flake8]
deps = flake8
changedir = {toxinidir}
commands = flake8 knox

[testenv:isort]
deps = isort
changedir = {toxinidir}
commands = isort --recursive --check-only --diff \
knox \
knox_project/views.py \
setup.py \
tests

[testenv]
commands =
python manage.py migrate
Expand All @@ -23,6 +33,7 @@ deps =
django21: Django>=2.1,<2.2
django-nose
markdown<3.0
isort
djangorestframework
freezegun
mkdocs
Expand Down

0 comments on commit 1e2adba

Please sign in to comment.