Skip to content

Commit

Permalink
Add isort to CI & re-add warnings (#762)
Browse files Browse the repository at this point in the history
* Add isort to tox/CI, re-add warning to CI

* Sort imports w/ first/third party ordering
  • Loading branch information
Ryan P Kilby authored and Carlton Gibson committed Aug 22, 2017
1 parent b56d2c3 commit 645f24a
Show file tree
Hide file tree
Showing 19 changed files with 62 additions and 8 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ script:
- coverage erase
- detox

matrix:
include:
- python: 3.6
env: TOXENV=isort
- python: 3.6
env: TOXENV=warnings

after_success:
- coverage combine --append
- coverage report -m
Expand Down
1 change: 1 addition & 0 deletions django_filters/rest_framework/filterset.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django import forms
from django.db import models
from django.utils.translation import ugettext_lazy as _

from django_filters import filterset

from .. import compat, utils
Expand Down
23 changes: 23 additions & 0 deletions docs/dev/tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,26 @@ supported versions of Python and Django. Install tox, and then simply run:

$ pip install tox
$ tox


Housekeeping
------------

The ``isort`` utility is used to maintain module imports. You can either test
the module imports with the appropriate `tox` env, or with `isort` directly.

.. code-block:: bash

$ pip install tox
$ tox -e isort

# or

$ pip install isort
$ isort --check-only --recursive django_filters tests

To sort the imports, simply remove the ``--check-only`` option.

.. code-block:: bash

$ isort --recursive django_filters tests
5 changes: 5 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ license-file = LICENSE
universal=1

[isort]
skip=.tox
atomic=true
multi_line_output=3
known_standard_library=mock
known_third_party=django,rest_framework
known_first_party=django_filters
5 changes: 3 additions & 2 deletions tests/rest_framework/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
from django.db.models import BooleanField
from django.test import TestCase
from django.test.utils import override_settings
from rest_framework import generics, serializers
from rest_framework.test import APIRequestFactory

from django_filters import compat, filters
from django_filters.rest_framework import (
DjangoFilterBackend,
FilterSet,
backends
)
from rest_framework import generics, serializers
from rest_framework.test import APIRequestFactory

from .models import FilterableItem

Expand Down
1 change: 1 addition & 0 deletions tests/rest_framework/test_filters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

from django.test import TestCase

from django_filters.rest_framework import filters
from django_filters.widgets import BooleanWidget

Expand Down
1 change: 1 addition & 0 deletions tests/rest_framework/test_filterset.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.conf import settings
from django.test import TestCase
from django.test.utils import override_settings

from django_filters.compat import is_crispy
from django_filters.rest_framework import FilterSet, filters
from django_filters.widgets import BooleanWidget
Expand Down
5 changes: 3 additions & 2 deletions tests/rest_framework/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
from django.test import TestCase
from django.test.utils import override_settings
from django.utils.dateparse import parse_date
from django_filters import STRICTNESS, filters
from django_filters.rest_framework import DjangoFilterBackend, FilterSet
from rest_framework import generics, serializers, status
from rest_framework.test import APIRequestFactory

from django_filters import STRICTNESS, filters
from django_filters.rest_framework import DjangoFilterBackend, FilterSet

from .models import (
BaseFilterableItem,
BasicModel,
Expand Down
1 change: 1 addition & 0 deletions tests/test_conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

from django.test import TestCase, override_settings

from django_filters import STRICTNESS, FilterSet
from django_filters.conf import is_callable, settings
from tests.models import User
Expand Down
1 change: 1 addition & 0 deletions tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django import forms
from django.test import TestCase, override_settings
from django.utils.timezone import get_default_timezone, make_aware

from django_filters.fields import (
BaseCSVField,
BaseRangeField,
Expand Down
3 changes: 2 additions & 1 deletion tests/test_filtering.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from __future__ import absolute_import, unicode_literals

import datetime
import mock
import unittest

import django
import mock
from django import forms
from django.test import TestCase, override_settings
from django.utils import six, timezone
from django.utils.timezone import now

from django_filters.exceptions import FieldLookupError
from django_filters.filters import (
AllValuesFilter,
Expand Down
3 changes: 2 additions & 1 deletion tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
from __future__ import absolute_import, unicode_literals

import inspect
import mock
from collections import OrderedDict
from datetime import date, datetime, time, timedelta

import mock
from django import forms
from django.test import TestCase, override_settings
from django.utils import translation
from django.utils.translation import ugettext as _

from django_filters import filters, widgets
from django_filters.fields import (
BaseCSVField,
Expand Down
3 changes: 2 additions & 1 deletion tests/test_filterset.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from __future__ import absolute_import, unicode_literals

import mock
import unittest

import django
import mock
from django.core.exceptions import ValidationError
from django.db import models
from django.test import TestCase, override_settings

from django_filters.constants import STRICTNESS
from django_filters.filters import (
BaseInFilter,
Expand Down
1 change: 1 addition & 0 deletions tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from django import forms
from django.test import TestCase, override_settings

from django_filters.filters import CharFilter, ChoiceFilter
from django_filters.filterset import FilterSet

Expand Down
1 change: 1 addition & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from django.test import TestCase, override_settings
from django.utils.functional import Promise
from django.utils.timezone import get_default_timezone

from django_filters import STRICTNESS, FilterSet
from django_filters.exceptions import FieldLookupError
from django_filters.utils import (
Expand Down
1 change: 1 addition & 0 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase, override_settings
from django.test.client import RequestFactory

from django_filters.filterset import FilterSet, filterset_factory
from django_filters.views import FilterView

Expand Down
1 change: 1 addition & 0 deletions tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from django.forms import Select, TextInput
from django.test import TestCase

from django_filters.widgets import (
BaseCSVWidget,
BooleanWidget,
Expand Down
1 change: 1 addition & 0 deletions tests/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import absolute_import, unicode_literals

from django.conf.urls import url

from django_filters.views import FilterView, object_filter

from .models import Book
Expand Down
6 changes: 5 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ envlist =
{py27,py34,py35}-django{19,110}-restframework36,
{py35,py36}-django111-restframework36,
{py35,py36}-djangolatest-restframeworklatest,
warnings
isort, warnings,

[testenv]
commands = coverage run --parallel-mode --source django_filters ./runtests.py {posargs}
Expand All @@ -22,6 +22,10 @@ deps =
restframeworklatest: https://github.com/tomchristie/django-rest-framework/archive/master.tar.gz
-rrequirements/test-ci.txt

[testenv:isort]
commands = isort --check-only --recursive django_filters tests {posargs}
deps = isort

[testenv:warnings]
ignore_outcome = True
commands = python -Werror ./runtests.py {posargs}
Expand Down

0 comments on commit 645f24a

Please sign in to comment.