diff --git a/.travis.yml b/.travis.yml index 9a0288a4..4f7a20fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ install: - pip install -r tests/requirements.txt script: - flake8 arq/ tests/ +- ./tests/isort_test.sh - py.test --cov=arq after_success: - coverage combine diff --git a/arq/cli.py b/arq/cli.py index 33f778ae..f156505e 100644 --- a/arq/cli.py +++ b/arq/cli.py @@ -1,10 +1,10 @@ import logging.config + import click from .version import VERSION from .worker import RunWorkerProcess, import_string - batch_help = 'Batch mode: exit once no jobs are found in any queue.' verbose_help = 'Enable verbose output.' diff --git a/arq/main.py b/arq/main.py index 93fff3dc..1003c4da 100644 --- a/arq/main.py +++ b/arq/main.py @@ -4,8 +4,7 @@ import msgpack -from .utils import RedisMixin, timestamp, ellipsis - +from .utils import RedisMixin, ellipsis, timestamp __all__ = ['Actor', 'concurrent', 'Job'] diff --git a/arq/testing.py b/arq/testing.py index 5efbf88d..f0f1942f 100644 --- a/arq/testing.py +++ b/arq/testing.py @@ -7,7 +7,7 @@ import pytest from aioredis import create_redis -from arq import RedisMixin, timestamp, BaseWorker +from arq import BaseWorker, RedisMixin, timestamp logger = logging.getLogger('arq.mock') diff --git a/arq/utils.py b/arq/utils.py index c0b577ed..330ea0d9 100644 --- a/arq/utils.py +++ b/arq/utils.py @@ -1,7 +1,7 @@ import asyncio import base64 -from datetime import datetime import os +from datetime import datetime import aioredis diff --git a/arq/worker.py b/arq/worker.py index 2d46937d..db22be03 100644 --- a/arq/worker.py +++ b/arq/worker.py @@ -1,16 +1,16 @@ import asyncio -from importlib import import_module, reload import logging -from multiprocessing import Process import os import signal -from signal import Signals import sys import time +from importlib import import_module, reload +from multiprocessing import Process +from signal import Signals from .logs import default_log_config from .main import Actor, Job -from .utils import RedisMixin, timestamp, cached_property, gen_random, ellipsis +from .utils import RedisMixin, cached_property, ellipsis, gen_random, timestamp __all__ = ['BaseWorker', 'import_string', 'RunWorkerProcess'] diff --git a/runtests.sh b/runtests.sh index 448c4dee..6bfa0602 100755 --- a/runtests.sh +++ b/runtests.sh @@ -6,8 +6,11 @@ if [ $pytest == 0 ] ; then coverage combine coverage html fi +./tests/isort_test.sh echo "pytest exit code: ${pytest}" +isort=$? +echo "isort exit code: ${isort}" flake8 arq/ tests/ flake=$? echo "flake8 exit code: ${flake}" -exit $((${flake} + ${pytest})) +exit $((${pytest} + ${flake} + ${isort})) diff --git a/tests/isort_test.sh b/tests/isort_test.sh new file mode 100755 index 00000000..d1a13e5c --- /dev/null +++ b/tests/isort_test.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +isort_result=$(isort -rc --wrap-length 120 --diff arq) +if [[ $isort_result == *"arq"* ]] ; then + printf "changes:\n $isort_result\n\nisort changed directory, therefore there's an import order problem\n" + exit 1 +fi +exit 0 diff --git a/tests/requirements.txt b/tests/requirements.txt index 16de66a2..478ebfcb 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,6 +1,7 @@ codecov coverage flake8 +isort pep8 pytest pytest-cov