diff --git a/celery/app/amqp.py b/celery/app/amqp.py index 63e15443e16..ca5a0ccaf02 100644 --- a/celery/app/amqp.py +++ b/celery/app/amqp.py @@ -8,6 +8,11 @@ from datetime import timedelta from weakref import WeakValueDictionary +from kombu import Connection, Consumer, Exchange, Producer, Queue, pools +from kombu.common import Broadcast +from kombu.utils.functional import maybe_list +from kombu.utils.objects import cached_property + from celery import signals from celery.five import items, string_t from celery.local import try_import @@ -15,10 +20,6 @@ from celery.utils.saferepr import saferepr from celery.utils.text import indent as textindent from celery.utils.time import maybe_make_aware -from kombu import Connection, Consumer, Exchange, Producer, Queue, pools -from kombu.common import Broadcast -from kombu.utils.functional import maybe_list -from kombu.utils.objects import cached_property from . import routes as _routes diff --git a/celery/app/base.py b/celery/app/base.py index 321473949f8..74d6f61676b 100644 --- a/celery/app/base.py +++ b/celery/app/base.py @@ -9,6 +9,15 @@ from datetime import datetime from operator import attrgetter +from kombu import pools +from kombu.clocks import LamportClock +from kombu.common import oid_from +from kombu.utils.compat import register_after_fork +from kombu.utils.objects import cached_property +from kombu.utils.uuid import uuid +from vine import starpromise +from vine.utils import wraps + from celery import platforms, signals from celery._state import (_announce_app_finalized, _deregister_app, _register_app, _set_current_app, _task_stack, @@ -28,14 +37,6 @@ from celery.utils.objects import FallbackContext, mro_lookup from celery.utils.time import (get_exponential_backoff_interval, timezone, to_utc) -from kombu import pools -from kombu.clocks import LamportClock -from kombu.common import oid_from -from kombu.utils.compat import register_after_fork -from kombu.utils.objects import cached_property -from kombu.utils.uuid import uuid -from vine import starpromise -from vine.utils import wraps # Load all builtin tasks from . import builtins # noqa diff --git a/celery/app/control.py b/celery/app/control.py index cd2e98e70d2..0a5b83e6fba 100644 --- a/celery/app/control.py +++ b/celery/app/control.py @@ -9,12 +9,13 @@ import warnings from billiard.common import TERM_SIGNAME -from celery.exceptions import DuplicateNodenameWarning -from celery.utils.text import pluralize from kombu.pidbox import Mailbox from kombu.utils.functional import lazy from kombu.utils.objects import cached_property +from celery.exceptions import DuplicateNodenameWarning +from celery.utils.text import pluralize + __all__ = ('Inspect', 'Control', 'flatten_reply') W_DUPNODE = """\ diff --git a/celery/app/log.py b/celery/app/log.py index 93b4c343f5e..78766650f3a 100644 --- a/celery/app/log.py +++ b/celery/app/log.py @@ -14,6 +14,8 @@ import sys from logging.handlers import WatchedFileHandler +from kombu.utils.encoding import set_default_encoding_file + from celery import signals from celery._state import get_current_task from celery.five import string_t @@ -24,7 +26,6 @@ reset_multiprocessing_logger) from celery.utils.nodenames import node_format from celery.utils.term import colored -from kombu.utils.encoding import set_default_encoding_file __all__ = ('TaskFormatter', 'Logging') diff --git a/celery/app/routes.py b/celery/app/routes.py index 78da604da2e..9957a4feae5 100644 --- a/celery/app/routes.py +++ b/celery/app/routes.py @@ -9,12 +9,13 @@ import string from collections import Mapping, OrderedDict +from kombu import Queue + from celery.exceptions import QueueNotFound from celery.five import items, string_t from celery.utils.collections import lpmerge from celery.utils.functional import maybe_evaluate, mlazy from celery.utils.imports import symbol_by_name -from kombu import Queue __all__ = ('MapRoute', 'Router', 'prepare') diff --git a/celery/app/task.py b/celery/app/task.py index 6268efe0fbd..6e3b8ad1732 100644 --- a/celery/app/task.py +++ b/celery/app/task.py @@ -5,6 +5,9 @@ import sys from billiard.einfo import ExceptionInfo +from kombu.exceptions import OperationalError +from kombu.utils.uuid import uuid + from celery import current_app, group, states from celery._state import _task_stack from celery.canvas import signature @@ -17,8 +20,6 @@ from celery.utils.imports import instantiate from celery.utils.nodenames import gethostname from celery.utils.serialization import raise_with_context -from kombu.exceptions import OperationalError -from kombu.utils.uuid import uuid from .annotations import resolve_all as resolve_all_annotations from .registry import _unpickle_task_v2 diff --git a/celery/app/trace.py b/celery/app/trace.py index c445ac9ccb3..f4c802f7548 100644 --- a/celery/app/trace.py +++ b/celery/app/trace.py @@ -13,10 +13,15 @@ from warnings import warn from billiard.einfo import ExceptionInfo +from kombu.exceptions import EncodeError +from kombu.serialization import loads as loads_message +from kombu.serialization import prepare_accept_content +from kombu.utils.encoding import safe_repr, safe_str + from celery import current_app, group, signals, states from celery._state import _task_stack -from celery.app.task import Task as BaseTask from celery.app.task import Context +from celery.app.task import Task as BaseTask from celery.exceptions import Ignore, InvalidTaskError, Reject, Retry from celery.five import monotonic, text_t from celery.utils.log import get_logger @@ -26,10 +31,6 @@ from celery.utils.serialization import (get_pickleable_etype, get_pickleable_exception, get_pickled_exception) -from kombu.exceptions import EncodeError -from kombu.serialization import loads as loads_message -from kombu.serialization import prepare_accept_content -from kombu.utils.encoding import safe_repr, safe_str # ## --- # This is the heart of the worker, the inner loop so to speak. diff --git a/celery/app/utils.py b/celery/app/utils.py index 3834a1523b8..186b80c6c8a 100644 --- a/celery/app/utils.py +++ b/celery/app/utils.py @@ -9,13 +9,14 @@ from copy import deepcopy from types import ModuleType +from kombu.utils.url import maybe_sanitize_url + from celery.exceptions import ImproperlyConfigured from celery.five import items, keys, string_t, values from celery.platforms import pyimplementation from celery.utils.collections import ConfigurationView from celery.utils.imports import import_from_cwd, qualname, symbol_by_name from celery.utils.text import pretty -from kombu.utils.url import maybe_sanitize_url from .defaults import (_OLD_DEFAULTS, _OLD_SETTING_KEYS, _TO_NEW_KEY, _TO_OLD_KEY, DEFAULTS, SETTING_KEYS, find) diff --git a/celery/apps/multi.py b/celery/apps/multi.py index 55a229e3f14..46e7a166e31 100644 --- a/celery/apps/multi.py +++ b/celery/apps/multi.py @@ -11,13 +11,14 @@ from subprocess import Popen from time import sleep +from kombu.utils.encoding import from_utf8 +from kombu.utils.objects import cached_property + from celery.five import UserList, items from celery.platforms import IS_WINDOWS, Pidfile, signal_name from celery.utils.nodenames import (gethostname, host_format, node_format, nodesplit) from celery.utils.saferepr import saferepr -from kombu.utils.encoding import from_utf8 -from kombu.utils.objects import cached_property __all__ = ('Cluster', 'Node') diff --git a/celery/apps/worker.py b/celery/apps/worker.py index ce492c7472d..49cc96086b7 100644 --- a/celery/apps/worker.py +++ b/celery/apps/worker.py @@ -17,6 +17,8 @@ from functools import partial from billiard.process import current_process +from kombu.utils.encoding import safe_str + from celery import VERSION_BANNER, platforms, signals from celery.app import trace from celery.exceptions import WorkerShutdown, WorkerTerminate @@ -29,7 +31,6 @@ from celery.utils.log import get_logger, in_sighandler, set_in_sighandler from celery.utils.text import pluralize from celery.worker import WorkController -from kombu.utils.encoding import safe_str __all__ = ('Worker',) diff --git a/celery/backends/amqp.py b/celery/backends/amqp.py index be7f9babcfd..d7e5456a361 100644 --- a/celery/backends/amqp.py +++ b/celery/backends/amqp.py @@ -6,12 +6,13 @@ from collections import deque from operator import itemgetter +from kombu import Consumer, Exchange, Producer, Queue + from celery import states from celery.exceptions import TimeoutError from celery.five import monotonic, range from celery.utils import deprecated from celery.utils.log import get_logger -from kombu import Consumer, Exchange, Producer, Queue from .base import BaseBackend diff --git a/celery/backends/async.py b/celery/backends/async.py index b5c6a96fc07..20bf5397d95 100644 --- a/celery/backends/async.py +++ b/celery/backends/async.py @@ -7,12 +7,13 @@ from time import sleep from weakref import WeakKeyDictionary +from kombu.utils.compat import detect_environment +from kombu.utils.objects import cached_property + from celery import states from celery.exceptions import TimeoutError from celery.five import Empty, monotonic from celery.utils.threads import THREAD_TIMEOUT_MAX -from kombu.utils.compat import detect_environment -from kombu.utils.objects import cached_property __all__ = ( 'AsyncBackendMixin', 'BaseResultConsumer', 'Drainer', diff --git a/celery/backends/base.py b/celery/backends/base.py index a6a16a6ac40..9f0ccd3eed0 100644 --- a/celery/backends/base.py +++ b/celery/backends/base.py @@ -15,6 +15,11 @@ from weakref import WeakValueDictionary from billiard.einfo import ExceptionInfo +from kombu.serialization import dumps, loads, prepare_accept_content +from kombu.serialization import registry as serializer_registry +from kombu.utils.encoding import bytes_to_str, ensure_bytes, from_utf8 +from kombu.utils.url import maybe_sanitize_url + from celery import current_app, group, maybe_signature, states from celery._state import get_current_task from celery.exceptions import (ChordError, ImproperlyConfigured, @@ -28,10 +33,6 @@ from celery.utils.serialization import (create_exception_cls, get_pickleable_exception, get_pickled_exception) -from kombu.serialization import registry as serializer_registry -from kombu.serialization import dumps, loads, prepare_accept_content -from kombu.utils.encoding import bytes_to_str, ensure_bytes, from_utf8 -from kombu.utils.url import maybe_sanitize_url __all__ = ('BaseBackend', 'KeyValueStoreBackend', 'DisabledBackend') diff --git a/celery/backends/cache.py b/celery/backends/cache.py index e8c2a68451f..32c44afb78d 100644 --- a/celery/backends/cache.py +++ b/celery/backends/cache.py @@ -4,11 +4,12 @@ import sys -from celery.exceptions import ImproperlyConfigured -from celery.utils.functional import LRUCache from kombu.utils.encoding import bytes_to_str, ensure_bytes from kombu.utils.objects import cached_property +from celery.exceptions import ImproperlyConfigured +from celery.utils.functional import LRUCache + from .base import KeyValueStoreBackend __all__ = ('CacheBackend',) diff --git a/celery/backends/consul.py b/celery/backends/consul.py index 5a917c515ee..8ac2ccbe19b 100644 --- a/celery/backends/consul.py +++ b/celery/backends/consul.py @@ -6,10 +6,11 @@ """ from __future__ import absolute_import, unicode_literals +from kombu.utils.url import parse_url + from celery.backends.base import PY3, KeyValueStoreBackend from celery.exceptions import ImproperlyConfigured from celery.utils.log import get_logger -from kombu.utils.url import parse_url try: import consul diff --git a/celery/backends/couchbase.py b/celery/backends/couchbase.py index 2a4c361ccd4..a9eb1d95234 100644 --- a/celery/backends/couchbase.py +++ b/celery/backends/couchbase.py @@ -4,10 +4,11 @@ import logging -from celery.exceptions import ImproperlyConfigured from kombu.utils.encoding import str_t from kombu.utils.url import _parse_url +from celery.exceptions import ImproperlyConfigured + from .base import KeyValueStoreBackend try: diff --git a/celery/backends/couchdb.py b/celery/backends/couchdb.py index 51f2c3e7f3d..6a81a571399 100644 --- a/celery/backends/couchdb.py +++ b/celery/backends/couchdb.py @@ -2,9 +2,10 @@ """CouchDB result store backend.""" from __future__ import absolute_import, unicode_literals -from celery.exceptions import ImproperlyConfigured from kombu.utils.url import _parse_url +from celery.exceptions import ImproperlyConfigured + from .base import KeyValueStoreBackend try: diff --git a/celery/backends/database/models.py b/celery/backends/database/models.py index a2c650ae75d..effdb4c28af 100644 --- a/celery/backends/database/models.py +++ b/celery/backends/database/models.py @@ -4,12 +4,12 @@ from datetime import datetime -from celery import states -from celery.five import python_2_unicode_compatible - import sqlalchemy as sa from sqlalchemy.types import PickleType +from celery import states +from celery.five import python_2_unicode_compatible + from .session import ResultModelBase __all__ = ('Task', 'TaskSet') diff --git a/celery/backends/database/session.py b/celery/backends/database/session.py index 12af35f0e6d..869ab354431 100644 --- a/celery/backends/database/session.py +++ b/celery/backends/database/session.py @@ -3,7 +3,6 @@ from __future__ import absolute_import, unicode_literals from kombu.utils.compat import register_after_fork - from sqlalchemy import create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker diff --git a/celery/backends/dynamodb.py b/celery/backends/dynamodb.py index 629e30b1277..26a84027dec 100644 --- a/celery/backends/dynamodb.py +++ b/celery/backends/dynamodb.py @@ -5,10 +5,11 @@ from collections import namedtuple from time import sleep, time +from kombu.utils.url import _parse_url as parse_url + from celery.exceptions import ImproperlyConfigured from celery.five import string from celery.utils.log import get_logger -from kombu.utils.url import _parse_url as parse_url from .base import KeyValueStoreBackend diff --git a/celery/backends/elasticsearch.py b/celery/backends/elasticsearch.py index 1a3d64f8b41..c160201e152 100644 --- a/celery/backends/elasticsearch.py +++ b/celery/backends/elasticsearch.py @@ -4,11 +4,12 @@ from datetime import datetime -from celery.exceptions import ImproperlyConfigured -from celery.five import items from kombu.utils.encoding import bytes_to_str from kombu.utils.url import _parse_url +from celery.exceptions import ImproperlyConfigured +from celery.five import items + from .base import KeyValueStoreBackend try: diff --git a/celery/backends/filesystem.py b/celery/backends/filesystem.py index 175c732959f..ab1a46132cf 100644 --- a/celery/backends/filesystem.py +++ b/celery/backends/filesystem.py @@ -5,10 +5,11 @@ import locale import os +from kombu.utils.encoding import ensure_bytes + from celery import uuid from celery.backends.base import KeyValueStoreBackend from celery.exceptions import ImproperlyConfigured -from kombu.utils.encoding import ensure_bytes # Python 2 does not have FileNotFoundError and IsADirectoryError try: diff --git a/celery/backends/mongodb.py b/celery/backends/mongodb.py index b20fc333fbe..5a0cfcc0a57 100644 --- a/celery/backends/mongodb.py +++ b/celery/backends/mongodb.py @@ -4,13 +4,14 @@ from datetime import datetime, timedelta -from celery import states -from celery.exceptions import ImproperlyConfigured -from celery.five import items, string_t from kombu.exceptions import EncodeError from kombu.utils.objects import cached_property from kombu.utils.url import maybe_sanitize_url +from celery import states +from celery.exceptions import ImproperlyConfigured +from celery.five import items, string_t + from .base import BaseBackend try: diff --git a/celery/backends/redis.py b/celery/backends/redis.py index 08a9b3f38c5..1042b9b9e0c 100644 --- a/celery/backends/redis.py +++ b/celery/backends/redis.py @@ -4,6 +4,10 @@ from functools import partial +from kombu.utils.functional import retry_over_time +from kombu.utils.objects import cached_property +from kombu.utils.url import _parse_url + from celery import states from celery._state import task_join_will_block from celery.canvas import maybe_signature @@ -13,9 +17,6 @@ from celery.utils.functional import dictfilter from celery.utils.log import get_logger from celery.utils.time import humanize_seconds -from kombu.utils.functional import retry_over_time -from kombu.utils.objects import cached_property -from kombu.utils.url import _parse_url from . import async, base diff --git a/celery/backends/riak.py b/celery/backends/riak.py index 9dad02fdd53..c5cdb68be52 100644 --- a/celery/backends/riak.py +++ b/celery/backends/riak.py @@ -4,9 +4,10 @@ import sys -from celery.exceptions import ImproperlyConfigured from kombu.utils.url import _parse_url +from celery.exceptions import ImproperlyConfigured + from .base import KeyValueStoreBackend try: diff --git a/celery/backends/rpc.py b/celery/backends/rpc.py index 7de35a14b10..6e31cef75e7 100644 --- a/celery/backends/rpc.py +++ b/celery/backends/rpc.py @@ -8,13 +8,14 @@ import time import kombu -from celery import states -from celery._state import current_task, task_join_will_block -from celery.five import items, range from kombu.common import maybe_declare from kombu.utils.compat import register_after_fork from kombu.utils.objects import cached_property +from celery import states +from celery._state import current_task, task_join_will_block +from celery.five import items, range + from . import base from .async import AsyncBackendMixin, BaseResultConsumer diff --git a/celery/bin/amqp.py b/celery/bin/amqp.py index 0f9ce8fd534..55414e25d75 100644 --- a/celery/bin/amqp.py +++ b/celery/bin/amqp.py @@ -12,11 +12,12 @@ from functools import partial from itertools import count +from kombu.utils.encoding import safe_str + from celery.bin.base import Command from celery.five import string_t from celery.utils.functional import padlist from celery.utils.serialization import strtobool -from kombu.utils.encoding import safe_str __all__ = ('AMQPAdmin', 'AMQShell', 'Spec', 'amqp') diff --git a/celery/bin/call.py b/celery/bin/call.py index 1661b29414e..ed71fc4460b 100644 --- a/celery/bin/call.py +++ b/celery/bin/call.py @@ -1,10 +1,11 @@ """The ``celery call`` program used to send tasks from the command-line.""" from __future__ import absolute_import, unicode_literals +from kombu.utils.json import loads + from celery.bin.base import Command from celery.five import string_t from celery.utils.time import maybe_iso8601 -from kombu.utils.json import loads class call(Command): diff --git a/celery/bin/control.py b/celery/bin/control.py index 512df266ebc..46411241527 100644 --- a/celery/bin/control.py +++ b/celery/bin/control.py @@ -1,12 +1,13 @@ """The ``celery control``, ``. inspect`` and ``. status`` programs.""" from __future__ import absolute_import, unicode_literals +from kombu.utils.json import dumps +from kombu.utils.objects import cached_property + from celery.bin.base import Command from celery.five import items, string_t from celery.platforms import EX_UNAVAILABLE, EX_USAGE from celery.utils import text -from kombu.utils.json import dumps -from kombu.utils.objects import cached_property class _RemoteControl(Command): diff --git a/celery/bin/multi.py b/celery/bin/multi.py index ed3572505b6..96e321e52fb 100644 --- a/celery/bin/multi.py +++ b/celery/bin/multi.py @@ -100,12 +100,13 @@ import sys from functools import wraps +from kombu.utils.objects import cached_property + from celery import VERSION_BANNER from celery.apps.multi import Cluster, MultiParser, NamespacedOptionParser from celery.platforms import EX_FAILURE, EX_OK, signals from celery.utils import term from celery.utils.text import pluralize -from kombu.utils.objects import cached_property __all__ = ('MultiTool',) diff --git a/celery/canvas.py b/celery/canvas.py index a3e19287515..b16a67268cc 100644 --- a/celery/canvas.py +++ b/celery/canvas.py @@ -16,20 +16,22 @@ from functools import reduce from operator import itemgetter +from kombu.utils.functional import fxrange, reprcall +from kombu.utils.objects import cached_property +from kombu.utils.uuid import uuid +from vine import barrier + from celery._state import current_app from celery.five import python_2_unicode_compatible from celery.local import try_import from celery.result import GroupResult from celery.utils import abstract +from celery.utils.functional import _regen from celery.utils.functional import chunks as _chunks -from celery.utils.functional import (_regen, is_list, maybe_list, regen, +from celery.utils.functional import (is_list, maybe_list, regen, seq_concat_item, seq_concat_seq) from celery.utils.objects import getitem_property from celery.utils.text import remove_repeating_from_task, truncate -from kombu.utils.functional import fxrange, reprcall -from kombu.utils.objects import cached_property -from kombu.utils.uuid import uuid -from vine import barrier __all__ = ( 'Signature', 'chain', 'xmap', 'xstarmap', 'chunks', diff --git a/celery/concurrency/asynpool.py b/celery/concurrency/asynpool.py index 373fc791602..ab261445338 100644 --- a/celery/concurrency/asynpool.py +++ b/celery/concurrency/asynpool.py @@ -34,16 +34,17 @@ from billiard.compat import buf_t, isblocking, setblocking from billiard.pool import ACK, NACK, RUN, TERMINATE, WorkersJoined from billiard.queues import _SimpleQueue -from celery.five import Counter, items, values -from celery.utils.functional import noop -from celery.utils.log import get_logger -from celery.worker import state as worker_state from kombu.async import ERR, WRITE from kombu.serialization import pickle as _pickle from kombu.utils.eventio import SELECT_BAD_FD from kombu.utils.functional import fxrange from vine import promise +from celery.five import Counter, items, values +from celery.utils.functional import noop +from celery.utils.log import get_logger +from celery.worker import state as worker_state + # pylint: disable=redefined-outer-name # We cache globals and attribute lookups, so disable this warning. diff --git a/celery/concurrency/base.py b/celery/concurrency/base.py index 29e55ecad96..62988ec56c1 100644 --- a/celery/concurrency/base.py +++ b/celery/concurrency/base.py @@ -8,12 +8,13 @@ from billiard.einfo import ExceptionInfo from billiard.exceptions import WorkerLostError +from kombu.utils.encoding import safe_repr + from celery.exceptions import WorkerShutdown, WorkerTerminate from celery.five import monotonic, reraise from celery.utils import timer2 from celery.utils.log import get_logger from celery.utils.text import truncate -from kombu.utils.encoding import safe_repr __all__ = ('BasePool', 'apply_target') diff --git a/celery/concurrency/eventlet.py b/celery/concurrency/eventlet.py index eaf505c44b8..b44dc515d30 100644 --- a/celery/concurrency/eventlet.py +++ b/celery/concurrency/eventlet.py @@ -4,10 +4,11 @@ import sys -from celery import signals # noqa from kombu.async import timer as _timer # noqa from kombu.five import monotonic +from celery import signals # noqa + from . import base # noqa __all__ = ('TaskPool',) diff --git a/celery/concurrency/prefork.py b/celery/concurrency/prefork.py index 0ea7de5c97a..820b895c8be 100644 --- a/celery/concurrency/prefork.py +++ b/celery/concurrency/prefork.py @@ -9,8 +9,9 @@ from billiard import forking_enable from billiard.common import REMAP_SIGTERM, TERM_SIGNAME -from billiard.pool import Pool as BlockingPool from billiard.pool import CLOSE, RUN +from billiard.pool import Pool as BlockingPool + from celery import platforms, signals from celery._state import _set_task_join_will_block, set_default_app from celery.app import trace diff --git a/celery/contrib/migrate.py b/celery/contrib/migrate.py index 2b44770ab40..88d0458e11c 100644 --- a/celery/contrib/migrate.py +++ b/celery/contrib/migrate.py @@ -6,13 +6,14 @@ from functools import partial from itertools import cycle, islice +from kombu import Queue, eventloop +from kombu.common import maybe_declare +from kombu.utils.encoding import ensure_bytes + from celery.app import app_or_default from celery.five import python_2_unicode_compatible, string, string_t from celery.utils.nodenames import worker_direct from celery.utils.text import str_to_list -from kombu import Queue, eventloop -from kombu.common import maybe_declare -from kombu.utils.encoding import ensure_bytes __all__ = ( 'StopFiltering', 'State', 'republish', 'migrate_task', diff --git a/celery/contrib/rdb.py b/celery/contrib/rdb.py index df7a7179834..019455000ef 100644 --- a/celery/contrib/rdb.py +++ b/celery/contrib/rdb.py @@ -50,6 +50,7 @@ def add(x, y): from pdb import Pdb from billiard.process import current_process + from celery.five import range __all__ = ( diff --git a/celery/contrib/sphinx.py b/celery/contrib/sphinx.py index 177d80c0b65..a39b6dcf276 100644 --- a/celery/contrib/sphinx.py +++ b/celery/contrib/sphinx.py @@ -31,7 +31,6 @@ from __future__ import absolute_import, unicode_literals from celery.app.task import BaseTask - from sphinx.domains.python import PyModulelevel from sphinx.ext.autodoc import FunctionDocumenter diff --git a/celery/contrib/testing/app.py b/celery/contrib/testing/app.py index e0d36368d52..3580c431655 100644 --- a/celery/contrib/testing/app.py +++ b/celery/contrib/testing/app.py @@ -5,9 +5,10 @@ from contextlib import contextmanager from copy import deepcopy -from celery import Celery, _state from kombu.utils.imports import symbol_by_name +from celery import Celery, _state + #: Contains the default configuration values for the test app. DEFAULT_TEST_CONFIG = { 'worker_hijack_root_logger': False, diff --git a/celery/contrib/testing/manager.py b/celery/contrib/testing/manager.py index 292b49434aa..909766c8424 100644 --- a/celery/contrib/testing/manager.py +++ b/celery/contrib/testing/manager.py @@ -7,12 +7,13 @@ from functools import partial from itertools import count +from kombu.utils.functional import retry_over_time + from celery.exceptions import TimeoutError from celery.five import items from celery.result import ResultSet from celery.utils.text import truncate from celery.utils.time import humanize_seconds as _humanize_seconds -from kombu.utils.functional import retry_over_time E_STILL_WAITING = 'Still waiting for {0}. Trying again {when}: {exc!r}' diff --git a/celery/events/dispatcher.py b/celery/events/dispatcher.py index 90ec4502805..fe9901d2339 100644 --- a/celery/events/dispatcher.py +++ b/celery/events/dispatcher.py @@ -6,11 +6,12 @@ import time from collections import defaultdict, deque +from kombu import Producer + from celery.app import app_or_default from celery.five import items from celery.utils.nodenames import anon_nodename from celery.utils.time import utcoffset -from kombu import Producer from .event import Event, get_exchange, group_from diff --git a/celery/events/receiver.py b/celery/events/receiver.py index 049f7c1c183..8c8775e4065 100644 --- a/celery/events/receiver.py +++ b/celery/events/receiver.py @@ -4,13 +4,14 @@ import time from operator import itemgetter -from celery import uuid -from celery.app import app_or_default -from celery.utils.time import adjust_timestamp from kombu import Queue from kombu.connection import maybe_channel from kombu.mixins import ConsumerMixin +from celery import uuid +from celery.app import app_or_default +from celery.utils.time import adjust_timestamp + from .event import get_exchange __all__ = ('EventReceiver',) diff --git a/celery/events/snapshot.py b/celery/events/snapshot.py index 8a2039935e9..aea58074060 100644 --- a/celery/events/snapshot.py +++ b/celery/events/snapshot.py @@ -9,6 +9,8 @@ """ from __future__ import absolute_import, print_function, unicode_literals +from kombu.utils.limits import TokenBucket + from celery import platforms from celery.app import app_or_default from celery.utils.dispatch import Signal @@ -16,7 +18,6 @@ from celery.utils.log import get_logger from celery.utils.time import rate from celery.utils.timer2 import Timer -from kombu.utils.limits import TokenBucket __all__ = ('Polaroid', 'evcam') diff --git a/celery/events/state.py b/celery/events/state.py index b5f14226a50..d046e47d01c 100644 --- a/celery/events/state.py +++ b/celery/events/state.py @@ -26,12 +26,13 @@ from time import time from weakref import WeakSet, ref +from kombu.clocks import timetuple +from kombu.utils.objects import cached_property + from celery import states from celery.five import items, python_2_unicode_compatible, values from celery.utils.functional import LRUCache, memoize, pass1 from celery.utils.log import get_logger -from kombu.clocks import timetuple -from kombu.utils.objects import cached_property __all__ = ('Worker', 'Task', 'State', 'heartbeat_expires') diff --git a/celery/fixups/django.py b/celery/fixups/django.py index f59bb862364..f53a079d6b8 100644 --- a/celery/fixups/django.py +++ b/celery/fixups/django.py @@ -7,11 +7,12 @@ from datetime import datetime from importlib import import_module -from celery import _state, signals -from celery.exceptions import FixupWarning, ImproperlyConfigured from kombu.utils.imports import symbol_by_name from kombu.utils.objects import cached_property +from celery import _state, signals +from celery.exceptions import FixupWarning, ImproperlyConfigured + __all__ = ('DjangoFixup', 'fixup') ERR_NOT_INSTALLED = """\ diff --git a/celery/loaders/base.py b/celery/loaders/base.py index bb6aab93050..74889ff85d1 100644 --- a/celery/loaders/base.py +++ b/celery/loaders/base.py @@ -8,14 +8,15 @@ import sys from datetime import datetime +from kombu.utils import json +from kombu.utils.objects import cached_property + from celery import signals from celery.five import reraise, string_t from celery.utils.collections import DictAttribute, force_mapping from celery.utils.functional import maybe_list from celery.utils.imports import (NotAPackage, find_module, import_from_cwd, symbol_by_name) -from kombu.utils import json -from kombu.utils.objects import cached_property __all__ = ('BaseLoader',) diff --git a/celery/security/certificate.py b/celery/security/certificate.py index 5fd3b1ce019..c9f1713a387 100644 --- a/celery/security/certificate.py +++ b/celery/security/certificate.py @@ -5,9 +5,10 @@ import glob import os +from kombu.utils.encoding import bytes_to_str + from celery.exceptions import SecurityError from celery.five import values -from kombu.utils.encoding import bytes_to_str from .utils import crypto, reraise_errors diff --git a/celery/security/serialization.py b/celery/security/serialization.py index 629156006c9..9f8411641eb 100644 --- a/celery/security/serialization.py +++ b/celery/security/serialization.py @@ -2,11 +2,12 @@ """Secure serializer.""" from __future__ import absolute_import, unicode_literals -from celery.five import bytes_if_py2 -from celery.utils.serialization import b64decode, b64encode from kombu.serialization import dumps, loads, registry from kombu.utils.encoding import bytes_to_str, ensure_bytes, str_to_bytes +from celery.five import bytes_if_py2 +from celery.utils.serialization import b64decode, b64encode + from .certificate import Certificate, FSCertStore from .key import PrivateKey from .utils import reraise_errors diff --git a/celery/task/base.py b/celery/task/base.py index ed7e998a6fb..f6170a06e43 100644 --- a/celery/task/base.py +++ b/celery/task/base.py @@ -8,14 +8,16 @@ """ from __future__ import absolute_import, unicode_literals +from kombu import Exchange + from celery import current_app +from celery.app.task import Context from celery.app.task import Task as BaseTask -from celery.app.task import Context, _reprtask +from celery.app.task import _reprtask from celery.five import python_2_unicode_compatible, with_metaclass from celery.local import Proxy, class_property, reclassmethod from celery.schedules import maybe_schedule from celery.utils.log import get_task_logger -from kombu import Exchange __all__ = ('Context', 'Task', 'TaskType', 'PeriodicTask', 'task') diff --git a/celery/utils/collections.py b/celery/utils/collections.py index 40f5bb03838..4fea4f61a79 100644 --- a/celery/utils/collections.py +++ b/celery/utils/collections.py @@ -3,9 +3,9 @@ from __future__ import absolute_import, unicode_literals import sys +from collections import Callable, Mapping, MutableMapping, MutableSet from collections import OrderedDict as _OrderedDict -from collections import (Callable, Mapping, MutableMapping, MutableSet, - Sequence, deque) +from collections import Sequence, deque from heapq import heapify, heappop, heappush from itertools import chain, count diff --git a/celery/utils/deprecated.py b/celery/utils/deprecated.py index 46f2bf807e5..1e07bb9b42a 100644 --- a/celery/utils/deprecated.py +++ b/celery/utils/deprecated.py @@ -4,9 +4,10 @@ import warnings -from celery.exceptions import CDeprecationWarning, CPendingDeprecationWarning from vine.utils import wraps +from celery.exceptions import CDeprecationWarning, CPendingDeprecationWarning + __all__ = ('Callable', 'Property', 'warn') diff --git a/celery/utils/dispatch/signal.py b/celery/utils/dispatch/signal.py index 1cf68da9ae1..d69506819f2 100644 --- a/celery/utils/dispatch/signal.py +++ b/celery/utils/dispatch/signal.py @@ -7,13 +7,14 @@ import warnings import weakref +from kombu.utils.functional import retry_over_time + from celery.exceptions import CDeprecationWarning from celery.five import python_2_unicode_compatible, range, text_t from celery.local import PromiseProxy, Proxy from celery.utils.functional import fun_accepts_kwargs from celery.utils.log import get_logger from celery.utils.time import humanize_seconds -from kombu.utils.functional import retry_over_time try: from weakref import WeakMethod diff --git a/celery/utils/functional.py b/celery/utils/functional.py index 52cc9586113..979fc135477 100644 --- a/celery/utils/functional.py +++ b/celery/utils/functional.py @@ -7,11 +7,12 @@ from functools import partial from itertools import chain, islice -from celery.five import UserList, getfullargspec, range from kombu.utils.functional import (LRUCache, dictfilter, is_list, lazy, maybe_evaluate, maybe_list, memoize) from vine import promise +from celery.five import UserList, getfullargspec, range + __all__ = ( 'LRUCache', 'is_list', 'maybe_list', 'memoize', 'mlazy', 'noop', 'first', 'firstmethod', 'chunks', 'padlist', 'mattrgetter', 'uniq', diff --git a/celery/utils/graph.py b/celery/utils/graph.py index 284f6b29ffd..2541a0ddc47 100644 --- a/celery/utils/graph.py +++ b/celery/utils/graph.py @@ -5,9 +5,10 @@ from collections import Counter from textwrap import dedent -from celery.five import items, python_2_unicode_compatible from kombu.utils.encoding import bytes_to_str, safe_str +from celery.five import items, python_2_unicode_compatible + __all__ = ('DOT', 'CycleError', 'DependencyGraph', 'GraphFormatter') diff --git a/celery/utils/imports.py b/celery/utils/imports.py index ff834561a6d..b264eaee496 100644 --- a/celery/utils/imports.py +++ b/celery/utils/imports.py @@ -9,9 +9,10 @@ import warnings from contextlib import contextmanager -from celery.five import reload from kombu.utils.imports import symbol_by_name +from celery.five import reload + #: Billiard sets this when execv is enabled. #: We use it to find out the name of the original ``__main__`` #: module, so that we can properly rewrite the name of the diff --git a/celery/utils/log.py b/celery/utils/log.py index a7490fb9ab1..b332d09a897 100644 --- a/celery/utils/log.py +++ b/celery/utils/log.py @@ -10,12 +10,13 @@ import traceback from contextlib import contextmanager -from celery.five import string_t, text_t from kombu.five import values -from kombu.log import get_logger as _get_logger from kombu.log import LOG_LEVELS +from kombu.log import get_logger as _get_logger from kombu.utils.encoding import safe_str +from celery.five import string_t, text_t + from .term import colored __all__ = ( diff --git a/celery/utils/serialization.py b/celery/utils/serialization.py index 121c0a09e5a..b71bd6e61da 100644 --- a/celery/utils/serialization.py +++ b/celery/utils/serialization.py @@ -11,9 +11,10 @@ from inspect import getmro from itertools import takewhile +from kombu.utils.encoding import bytes_to_str, str_to_bytes + from celery.five import (bytes_if_py2, items, python_2_unicode_compatible, reraise, string_t) -from kombu.utils.encoding import bytes_to_str, str_to_bytes from .encoding import safe_repr diff --git a/celery/utils/time.py b/celery/utils/time.py index f664604d9d2..4aea9a973fd 100644 --- a/celery/utils/time.py +++ b/celery/utils/time.py @@ -10,11 +10,12 @@ from calendar import monthrange from datetime import date, datetime, timedelta, tzinfo -from celery.five import python_2_unicode_compatible, string_t from kombu.utils.functional import reprcall from kombu.utils.objects import cached_property -from pytz import timezone as _timezone from pytz import AmbiguousTimeError, FixedOffset +from pytz import timezone as _timezone + +from celery.five import python_2_unicode_compatible, string_t from .functional import dictfilter from .iso8601 import parse_iso8601 diff --git a/celery/utils/timer2.py b/celery/utils/timer2.py index 3c7cf3bf4eb..8d8907166a8 100644 --- a/celery/utils/timer2.py +++ b/celery/utils/timer2.py @@ -13,9 +13,11 @@ from itertools import count from time import sleep -from celery.five import THREAD_TIMEOUT_MAX +from kombu.async.timer import Entry from kombu.async.timer import Timer as Schedule -from kombu.async.timer import Entry, logger, to_timestamp +from kombu.async.timer import logger, to_timestamp + +from celery.five import THREAD_TIMEOUT_MAX TIMER_DEBUG = os.environ.get('TIMER_DEBUG') diff --git a/celery/worker/autoscale.py b/celery/worker/autoscale.py index 1a3240b8943..a5b21543347 100644 --- a/celery/worker/autoscale.py +++ b/celery/worker/autoscale.py @@ -14,11 +14,12 @@ import threading from time import sleep +from kombu.async.semaphore import DummyLock + from celery import bootsteps from celery.five import monotonic from celery.utils.log import get_logger from celery.utils.threads import bgThread -from kombu.async.semaphore import DummyLock from . import state from .components import Pool diff --git a/celery/worker/components.py b/celery/worker/components.py index 6bc03ec552c..7995ee1017c 100644 --- a/celery/worker/components.py +++ b/celery/worker/components.py @@ -5,16 +5,17 @@ import atexit import warnings +from kombu.async import Hub as _Hub +from kombu.async import get_event_loop, set_event_loop +from kombu.async.semaphore import DummyLock, LaxBoundedSemaphore +from kombu.async.timer import Timer as _Timer + from celery import bootsteps from celery._state import _set_task_join_will_block from celery.exceptions import ImproperlyConfigured from celery.five import string_t from celery.platforms import IS_WINDOWS from celery.utils.log import worker_logger as logger -from kombu.async import Hub as _Hub -from kombu.async import get_event_loop, set_event_loop -from kombu.async.semaphore import DummyLock, LaxBoundedSemaphore -from kombu.async.timer import Timer as _Timer __all__ = ('Timer', 'Hub', 'Pool', 'Beat', 'StateDB', 'Consumer') diff --git a/celery/worker/consumer/connection.py b/celery/worker/consumer/connection.py index 98228cb889e..c0a3f7013d3 100644 --- a/celery/worker/consumer/connection.py +++ b/celery/worker/consumer/connection.py @@ -1,9 +1,10 @@ """Consumer Broker Connection Bootstep.""" from __future__ import absolute_import, unicode_literals +from kombu.common import ignore_errors + from celery import bootsteps from celery.utils.log import get_logger -from kombu.common import ignore_errors __all__ = ('Connection',) diff --git a/celery/worker/consumer/consumer.py b/celery/worker/consumer/consumer.py index 92298b571f7..41e16f31b5f 100644 --- a/celery/worker/consumer/consumer.py +++ b/celery/worker/consumer/consumer.py @@ -15,6 +15,12 @@ from billiard.common import restart_state from billiard.exceptions import RestartFreqExceeded +from kombu.async.semaphore import DummyLock +from kombu.utils.compat import _detect_environment +from kombu.utils.encoding import bytes_t, safe_repr +from kombu.utils.limits import TokenBucket +from vine import ppartial, promise + from celery import bootsteps, signals from celery.app.trace import build_tracer from celery.exceptions import InvalidTaskError, NotRegistered @@ -28,11 +34,6 @@ from celery.worker import loops from celery.worker.state import (maybe_shutdown, reserved_requests, task_reserved) -from kombu.async.semaphore import DummyLock -from kombu.utils.compat import _detect_environment -from kombu.utils.encoding import bytes_t, safe_repr -from kombu.utils.limits import TokenBucket -from vine import ppartial, promise __all__ = ('Consumer', 'Evloop', 'dump_body') diff --git a/celery/worker/consumer/events.py b/celery/worker/consumer/events.py index c2a3fe5a24f..d7b9f003930 100644 --- a/celery/worker/consumer/events.py +++ b/celery/worker/consumer/events.py @@ -4,9 +4,10 @@ """ from __future__ import absolute_import, unicode_literals -from celery import bootsteps from kombu.common import ignore_errors +from celery import bootsteps + from .connection import Connection __all__ = ('Events',) diff --git a/celery/worker/consumer/gossip.py b/celery/worker/consumer/gossip.py index bd5aebbc021..de1d45e73ff 100644 --- a/celery/worker/consumer/gossip.py +++ b/celery/worker/consumer/gossip.py @@ -6,12 +6,13 @@ from heapq import heappush from operator import itemgetter +from kombu import Consumer +from kombu.async.semaphore import DummyLock + from celery import bootsteps from celery.five import values from celery.utils.log import get_logger from celery.utils.objects import Bunch -from kombu import Consumer -from kombu.async.semaphore import DummyLock from .mingle import Mingle diff --git a/celery/worker/consumer/tasks.py b/celery/worker/consumer/tasks.py index 9b1015a87c3..030a2009187 100644 --- a/celery/worker/consumer/tasks.py +++ b/celery/worker/consumer/tasks.py @@ -1,9 +1,10 @@ """Worker Task Consumer Bootstep.""" from __future__ import absolute_import, unicode_literals +from kombu.common import QoS, ignore_errors + from celery import bootsteps from celery.utils.log import get_logger -from kombu.common import QoS, ignore_errors from .mingle import Mingle diff --git a/celery/worker/control.py b/celery/worker/control.py index 0f85b3b5932..5d514bdae51 100644 --- a/celery/worker/control.py +++ b/celery/worker/control.py @@ -7,6 +7,8 @@ from collections import namedtuple from billiard.common import TERM_SIGNAME +from kombu.utils.encoding import safe_repr + from celery.exceptions import WorkerShutdown from celery.five import UserDict, items, string_t, text_t from celery.platforms import signals as _signals @@ -14,7 +16,6 @@ from celery.utils.log import get_logger from celery.utils.serialization import jsonify, strtobool from celery.utils.time import rate -from kombu.utils.encoding import safe_repr from . import state as worker_state from .request import Request diff --git a/celery/worker/pidbox.py b/celery/worker/pidbox.py index 862a419fdfd..815204dcc19 100644 --- a/celery/worker/pidbox.py +++ b/celery/worker/pidbox.py @@ -4,11 +4,12 @@ import socket import threading +from kombu.common import ignore_errors +from kombu.utils.encoding import safe_str + from celery.utils.collections import AttributeDict from celery.utils.functional import pass1 from celery.utils.log import get_logger -from kombu.common import ignore_errors -from kombu.utils.encoding import safe_str from . import control diff --git a/celery/worker/request.py b/celery/worker/request.py index 4988fbb4328..73124399144 100644 --- a/celery/worker/request.py +++ b/celery/worker/request.py @@ -12,6 +12,9 @@ from weakref import ref from billiard.common import TERM_SIGNAME +from kombu.utils.encoding import safe_repr, safe_str +from kombu.utils.objects import cached_property + from celery import signals from celery.app.trace import trace_task, trace_task_ret from celery.exceptions import (Ignore, InvalidTaskError, Reject, Retry, @@ -24,8 +27,6 @@ from celery.utils.nodenames import gethostname from celery.utils.serialization import get_pickled_exception from celery.utils.time import maybe_iso8601, maybe_make_aware, timezone -from kombu.utils.encoding import safe_repr, safe_str -from kombu.utils.objects import cached_property from . import state diff --git a/celery/worker/state.py b/celery/worker/state.py index 2f42f216d06..cb64a5afcba 100644 --- a/celery/worker/state.py +++ b/celery/worker/state.py @@ -13,12 +13,13 @@ import weakref import zlib +from kombu.serialization import pickle, pickle_protocol +from kombu.utils.objects import cached_property + from celery import __version__ from celery.exceptions import WorkerShutdown, WorkerTerminate from celery.five import Counter from celery.utils.collections import LimitedSet -from kombu.serialization import pickle, pickle_protocol -from kombu.utils.objects import cached_property __all__ = ( 'SOFTWARE_INFO', 'reserved_requests', 'active_requests', diff --git a/celery/worker/strategy.py b/celery/worker/strategy.py index efaeb18c237..541c46a0a01 100644 --- a/celery/worker/strategy.py +++ b/celery/worker/strategy.py @@ -4,13 +4,14 @@ import logging +from kombu.async.timer import to_timestamp +from kombu.five import buffer_t + from celery.exceptions import InvalidTaskError from celery.utils.imports import symbol_by_name from celery.utils.log import get_logger from celery.utils.saferepr import saferepr from celery.utils.time import timezone -from kombu.async.timer import to_timestamp -from kombu.five import buffer_t from .request import create_request_cls from .state import task_reserved diff --git a/celery/worker/worker.py b/celery/worker/worker.py index cc75381fe85..de0a3ccbdf9 100644 --- a/celery/worker/worker.py +++ b/celery/worker/worker.py @@ -18,20 +18,22 @@ import sys from billiard import cpu_count +from kombu.utils.compat import detect_environment + +from celery import bootsteps from celery import concurrency as _concurrency -from celery import bootsteps, signals +from celery import signals from celery.bootsteps import RUN, TERMINATE from celery.exceptions import (ImproperlyConfigured, TaskRevokedError, WorkerTerminate) from celery.five import python_2_unicode_compatible, values from celery.platforms import EX_FAILURE, create_pidlock from celery.utils.imports import reload_from_cwd -from celery.utils.log import worker_logger as logger from celery.utils.log import mlevel +from celery.utils.log import worker_logger as logger from celery.utils.nodenames import default_nodename, worker_direct from celery.utils.text import str_to_list from celery.utils.threads import default_socket_timeout -from kombu.utils.compat import detect_environment from . import state diff --git a/t/benchmarks/bench_worker.py b/t/benchmarks/bench_worker.py index 8e3554a729d..8cdc3bdaf4a 100644 --- a/t/benchmarks/bench_worker.py +++ b/t/benchmarks/bench_worker.py @@ -3,9 +3,10 @@ import os import sys +from kombu.five import monotonic # noqa + from celery import Celery # noqa from celery.five import range # noqa -from kombu.five import monotonic # noqa os.environ.update( NOSETPS='yes', diff --git a/t/integration/conftest.py b/t/integration/conftest.py index 7ed2b154be3..f4e5bcf7b50 100644 --- a/t/integration/conftest.py +++ b/t/integration/conftest.py @@ -4,6 +4,7 @@ from functools import wraps import pytest + from celery.contrib.testing.manager import Manager TEST_BROKER = os.environ.get('TEST_BROKER', 'pyamqp://') diff --git a/t/integration/test_canvas.py b/t/integration/test_canvas.py index bd3578262f3..b82f0993403 100644 --- a/t/integration/test_canvas.py +++ b/t/integration/test_canvas.py @@ -1,12 +1,12 @@ from __future__ import absolute_import, unicode_literals import pytest +from redis import StrictRedis + from celery import chain, chord, group from celery.exceptions import TimeoutError from celery.result import AsyncResult, GroupResult -from redis import StrictRedis - from .conftest import flaky from .tasks import add, add_replaced, add_to_all, collect_ids, ids, redis_echo diff --git a/t/unit/app/test_amqp.py b/t/unit/app/test_amqp.py index 1d0bc9e0a53..f7ec11f19b7 100644 --- a/t/unit/app/test_amqp.py +++ b/t/unit/app/test_amqp.py @@ -4,11 +4,12 @@ import pytest from case import Mock +from kombu import Exchange, Queue + from celery import uuid from celery.app.amqp import Queues, utf8dict from celery.five import keys from celery.utils.time import to_utc -from kombu import Exchange, Queue class test_TaskConsumer: diff --git a/t/unit/app/test_app.py b/t/unit/app/test_app.py index fd7d2e95b9f..6cf04b05a19 100644 --- a/t/unit/app/test_app.py +++ b/t/unit/app/test_app.py @@ -9,8 +9,11 @@ import pytest from case import ContextMock, Mock, mock, patch +from vine import promise + +from celery import Celery, _state from celery import app as _app -from celery import Celery, _state, current_app, shared_task +from celery import current_app, shared_task from celery.app import base as _appbase from celery.app import defaults from celery.exceptions import ImproperlyConfigured @@ -21,7 +24,6 @@ from celery.utils.objects import Bunch from celery.utils.serialization import pickle from celery.utils.time import localize, timezone, to_utc -from vine import promise THIS_IS_A_KEY = 'this is a value' diff --git a/t/unit/app/test_backends.py b/t/unit/app/test_backends.py index c28a85e3cfa..38b801ac018 100644 --- a/t/unit/app/test_backends.py +++ b/t/unit/app/test_backends.py @@ -2,6 +2,7 @@ import pytest from case import patch + from celery.app import backends from celery.backends.amqp import AMQPBackend from celery.backends.cache import CacheBackend diff --git a/t/unit/app/test_beat.py b/t/unit/app/test_beat.py index d1a9261fcfb..39d5613a30f 100644 --- a/t/unit/app/test_beat.py +++ b/t/unit/app/test_beat.py @@ -6,6 +6,7 @@ import pytest from case import Mock, call, patch, skip + from celery import beat, uuid from celery.beat import event_t from celery.five import keys, string_t diff --git a/t/unit/app/test_builtins.py b/t/unit/app/test_builtins.py index 2c56c59d0a6..d7ed0e812d8 100644 --- a/t/unit/app/test_builtins.py +++ b/t/unit/app/test_builtins.py @@ -2,6 +2,7 @@ import pytest from case import ContextMock, Mock, patch + from celery import chord, group from celery.app import builtins from celery.five import range diff --git a/t/unit/app/test_celery.py b/t/unit/app/test_celery.py index acdeca45e39..3ed66151b94 100644 --- a/t/unit/app/test_celery.py +++ b/t/unit/app/test_celery.py @@ -1,8 +1,9 @@ from __future__ import absolute_import, unicode_literals -import celery import pytest +import celery + def test_version(): assert celery.VERSION diff --git a/t/unit/app/test_control.py b/t/unit/app/test_control.py index 0be66cd06bc..394b8cec48f 100644 --- a/t/unit/app/test_control.py +++ b/t/unit/app/test_control.py @@ -2,6 +2,7 @@ import pytest from case import Mock + from celery import uuid from celery.app import control from celery.exceptions import DuplicateNodenameWarning diff --git a/t/unit/app/test_defaults.py b/t/unit/app/test_defaults.py index 70962b5ef31..aca3e2dc8d6 100644 --- a/t/unit/app/test_defaults.py +++ b/t/unit/app/test_defaults.py @@ -4,6 +4,7 @@ from importlib import import_module from case import mock + from celery.app.defaults import (_OLD_DEFAULTS, _OLD_SETTING_KEYS, _TO_NEW_KEY, _TO_OLD_KEY, DEFAULTS, NAMESPACES, SETTING_KEYS) diff --git a/t/unit/app/test_loaders.py b/t/unit/app/test_loaders.py index b99ed82e8f9..f3d5265e7fb 100644 --- a/t/unit/app/test_loaders.py +++ b/t/unit/app/test_loaders.py @@ -6,6 +6,7 @@ import pytest from case import Mock, mock, patch + from celery import loaders from celery.exceptions import NotConfigured from celery.five import bytes_if_py2 diff --git a/t/unit/app/test_log.py b/t/unit/app/test_log.py index 20611a9e266..01452ffcbf8 100644 --- a/t/unit/app/test_log.py +++ b/t/unit/app/test_log.py @@ -9,13 +9,14 @@ import pytest from case import Mock, mock, patch, skip from case.utils import get_logger_handlers + from celery import signals, uuid from celery.app.log import TaskFormatter from celery.five import python_2_unicode_compatible -from celery.utils.log import logger as base_logger from celery.utils.log import (ColorFormatter, LoggingProxy, get_logger, - get_task_logger, in_sighandler, logger_isa, - task_logger) + get_task_logger, in_sighandler) +from celery.utils.log import logger as base_logger +from celery.utils.log import logger_isa, task_logger class test_TaskFormatter: diff --git a/t/unit/app/test_registry.py b/t/unit/app/test_registry.py index 065e4109f53..d4bb093ff69 100644 --- a/t/unit/app/test_registry.py +++ b/t/unit/app/test_registry.py @@ -1,6 +1,7 @@ from __future__ import absolute_import, unicode_literals import pytest + from celery.app.registry import _unpickle_task, _unpickle_task_v2 from celery.exceptions import InvalidTaskError diff --git a/t/unit/app/test_routes.py b/t/unit/app/test_routes.py index 8090c9f7df9..8d3eac04178 100644 --- a/t/unit/app/test_routes.py +++ b/t/unit/app/test_routes.py @@ -2,12 +2,13 @@ import pytest from case import ANY, Mock +from kombu import Exchange, Queue +from kombu.utils.functional import maybe_evaluate + from celery.app import routes from celery.exceptions import QueueNotFound from celery.five import items from celery.utils.imports import qualname -from kombu import Exchange, Queue -from kombu.utils.functional import maybe_evaluate def Router(app, *args, **kwargs): diff --git a/t/unit/app/test_schedules.py b/t/unit/app/test_schedules.py index 8feb5ddb0ca..a7b3025384f 100644 --- a/t/unit/app/test_schedules.py +++ b/t/unit/app/test_schedules.py @@ -7,12 +7,12 @@ import pytest import pytz +from case import Case, Mock, skip + from celery.five import items from celery.schedules import (ParseException, crontab, crontab_parser, schedule, solar) -from case import Case, Mock, skip - assertions = Case('__init__') diff --git a/t/unit/app/test_utils.py b/t/unit/app/test_utils.py index a154bfffa1b..4332d87ca28 100644 --- a/t/unit/app/test_utils.py +++ b/t/unit/app/test_utils.py @@ -3,6 +3,7 @@ from collections import Mapping, MutableMapping from case import Mock + from celery.app.utils import Settings, bugreport, filter_hidden_settings diff --git a/t/unit/apps/test_multi.py b/t/unit/apps/test_multi.py index 1c51607b39e..57f101b08d7 100644 --- a/t/unit/apps/test_multi.py +++ b/t/unit/apps/test_multi.py @@ -6,6 +6,7 @@ import pytest from case import Mock, call, patch, skip + from celery.apps.multi import (Cluster, MultiParser, NamespacedOptionParser, Node, format_opt) diff --git a/t/unit/backends/test_amqp.py b/t/unit/backends/test_amqp.py index 89cc1e339aa..b609e8c3782 100644 --- a/t/unit/backends/test_amqp.py +++ b/t/unit/backends/test_amqp.py @@ -8,6 +8,7 @@ import pytest from billiard.einfo import ExceptionInfo from case import Mock, mock + from celery import states, uuid from celery.backends.amqp import AMQPBackend from celery.five import Empty, Queue, range diff --git a/t/unit/backends/test_base.py b/t/unit/backends/test_base.py index 970ce223d60..09612d75249 100644 --- a/t/unit/backends/test_base.py +++ b/t/unit/backends/test_base.py @@ -6,6 +6,7 @@ import pytest from case import ANY, Mock, call, patch, skip + from celery import chord, group, states, uuid from celery.backends.base import (BaseBackend, DisabledBackend, KeyValueStoreBackend, _nulldict) @@ -14,10 +15,10 @@ from celery.result import result_from_tuple from celery.utils import serialization from celery.utils.functional import pass1 +from celery.utils.serialization import UnpickleableExceptionWrapper from celery.utils.serialization import find_pickleable_exception as fnpe from celery.utils.serialization import get_pickleable_exception as gpe -from celery.utils.serialization import (UnpickleableExceptionWrapper, - subclass_exception) +from celery.utils.serialization import subclass_exception class wrapobject(object): diff --git a/t/unit/backends/test_cache.py b/t/unit/backends/test_cache.py index 847fb3db52c..019c6548793 100644 --- a/t/unit/backends/test_cache.py +++ b/t/unit/backends/test_cache.py @@ -6,11 +6,12 @@ import pytest from case import Mock, mock, patch, skip +from kombu.utils.encoding import ensure_bytes, str_to_bytes + from celery import group, signature, states, uuid from celery.backends.cache import CacheBackend, DummyClient, backends from celery.exceptions import ImproperlyConfigured from celery.five import bytes_if_py2, items, string, text_t -from kombu.utils.encoding import ensure_bytes, str_to_bytes PY3 = sys.version_info[0] == 3 diff --git a/t/unit/backends/test_cassandra.py b/t/unit/backends/test_cassandra.py index ff745297883..fb109438613 100644 --- a/t/unit/backends/test_cassandra.py +++ b/t/unit/backends/test_cassandra.py @@ -5,6 +5,7 @@ import pytest from case import Mock, mock + from celery import states from celery.exceptions import ImproperlyConfigured from celery.utils.objects import Bunch diff --git a/t/unit/backends/test_consul.py b/t/unit/backends/test_consul.py index 0d4f521664d..a992abd9364 100644 --- a/t/unit/backends/test_consul.py +++ b/t/unit/backends/test_consul.py @@ -1,6 +1,7 @@ from __future__ import absolute_import, unicode_literals from case import Mock, skip + from celery.backends.consul import ConsulBackend diff --git a/t/unit/backends/test_couchbase.py b/t/unit/backends/test_couchbase.py index 1302d990233..cf4847c28f3 100644 --- a/t/unit/backends/test_couchbase.py +++ b/t/unit/backends/test_couchbase.py @@ -3,11 +3,12 @@ import pytest from case import MagicMock, Mock, patch, sentinel, skip +from kombu.utils.encoding import str_t + from celery.app import backends from celery.backends import couchbase as module from celery.backends.couchbase import CouchbaseBackend from celery.exceptions import ImproperlyConfigured -from kombu.utils.encoding import str_t try: import couchbase diff --git a/t/unit/backends/test_couchdb.py b/t/unit/backends/test_couchdb.py index 13c85ccba7a..e3aa0fbb149 100644 --- a/t/unit/backends/test_couchdb.py +++ b/t/unit/backends/test_couchdb.py @@ -2,6 +2,7 @@ import pytest from case import MagicMock, Mock, sentinel, skip + from celery.app import backends from celery.backends import couchdb as module from celery.backends.couchdb import CouchBackend diff --git a/t/unit/backends/test_database.py b/t/unit/backends/test_database.py index 3929d9b113d..eb016743261 100644 --- a/t/unit/backends/test_database.py +++ b/t/unit/backends/test_database.py @@ -5,6 +5,7 @@ import pytest from case import Mock, patch, skip + from celery import states, uuid from celery.exceptions import ImproperlyConfigured diff --git a/t/unit/backends/test_dynamodb.py b/t/unit/backends/test_dynamodb.py index c86c3317dd9..11107529774 100644 --- a/t/unit/backends/test_dynamodb.py +++ b/t/unit/backends/test_dynamodb.py @@ -5,6 +5,7 @@ import pytest from case import MagicMock, Mock, patch, sentinel, skip + from celery.backends import dynamodb as module from celery.backends.dynamodb import DynamoDBBackend from celery.exceptions import ImproperlyConfigured diff --git a/t/unit/backends/test_elasticsearch.py b/t/unit/backends/test_elasticsearch.py index d056d658c07..dc6b4b60be5 100644 --- a/t/unit/backends/test_elasticsearch.py +++ b/t/unit/backends/test_elasticsearch.py @@ -2,6 +2,7 @@ import pytest from case import Mock, sentinel, skip + from celery.app import backends from celery.backends import elasticsearch as module from celery.backends.elasticsearch import ElasticsearchBackend diff --git a/t/unit/backends/test_filesystem.py b/t/unit/backends/test_filesystem.py index 71095736b7d..7b755d95229 100644 --- a/t/unit/backends/test_filesystem.py +++ b/t/unit/backends/test_filesystem.py @@ -6,6 +6,7 @@ import pytest from case import skip + from celery import states, uuid from celery.backends.filesystem import FilesystemBackend from celery.exceptions import ImproperlyConfigured diff --git a/t/unit/backends/test_mongodb.py b/t/unit/backends/test_mongodb.py index e0f4d712a7b..98cd3c914f5 100644 --- a/t/unit/backends/test_mongodb.py +++ b/t/unit/backends/test_mongodb.py @@ -5,10 +5,11 @@ import pytest from case import ANY, MagicMock, Mock, mock, patch, sentinel, skip +from kombu.exceptions import EncodeError + from celery import states, uuid from celery.backends.mongodb import InvalidDocument, MongoBackend from celery.exceptions import ImproperlyConfigured -from kombu.exceptions import EncodeError COLLECTION = 'taskmeta_celery' TASK_ID = uuid() diff --git a/t/unit/backends/test_redis.py b/t/unit/backends/test_redis.py index 0ed4ff893f4..2acd1b1dbda 100644 --- a/t/unit/backends/test_redis.py +++ b/t/unit/backends/test_redis.py @@ -8,6 +8,7 @@ import pytest from case import ANY, ContextMock, Mock, call, mock, patch, skip + from celery import signature, states, uuid from celery.canvas import Signature from celery.exceptions import (ChordError, CPendingDeprecationWarning, diff --git a/t/unit/backends/test_riak.py b/t/unit/backends/test_riak.py index 0ea6e8086bc..008a5cf7b06 100644 --- a/t/unit/backends/test_riak.py +++ b/t/unit/backends/test_riak.py @@ -3,6 +3,7 @@ import pytest from case import MagicMock, Mock, patch, sentinel, skip + from celery.backends import riak as module from celery.backends.riak import RiakBackend from celery.exceptions import ImproperlyConfigured diff --git a/t/unit/backends/test_rpc.py b/t/unit/backends/test_rpc.py index 25462595951..ccb26e7c487 100644 --- a/t/unit/backends/test_rpc.py +++ b/t/unit/backends/test_rpc.py @@ -2,6 +2,7 @@ import pytest from case import Mock, patch + from celery import chord, group from celery._state import _task_stack from celery.backends.rpc import RPCBackend diff --git a/t/unit/bin/test_amqp.py b/t/unit/bin/test_amqp.py index aa80e62bdda..924befb7c40 100644 --- a/t/unit/bin/test_amqp.py +++ b/t/unit/bin/test_amqp.py @@ -2,6 +2,7 @@ import pytest from case import Mock, patch + from celery.bin.amqp import AMQPAdmin, AMQShell, amqp, dump_message, main from celery.five import WhateverIO diff --git a/t/unit/bin/test_base.py b/t/unit/bin/test_base.py index 293497f0fc6..dbcc3292d12 100644 --- a/t/unit/bin/test_base.py +++ b/t/unit/bin/test_base.py @@ -4,6 +4,7 @@ import pytest from case import Mock, mock, patch + from celery.bin.base import Command, Extensions, Option from celery.five import bytes_if_py2 diff --git a/t/unit/bin/test_beat.py b/t/unit/bin/test_beat.py index 774f0afc6e8..1d5b81074b1 100644 --- a/t/unit/bin/test_beat.py +++ b/t/unit/bin/test_beat.py @@ -5,6 +5,7 @@ import pytest from case import Mock, mock, patch + from celery import beat, platforms from celery.apps import beat as beatapp from celery.bin import beat as beat_bin diff --git a/t/unit/bin/test_call.py b/t/unit/bin/test_call.py index ba3a88510f2..c6ad765c945 100644 --- a/t/unit/bin/test_call.py +++ b/t/unit/bin/test_call.py @@ -4,9 +4,10 @@ import pytest from case import patch +from kombu.utils.json import dumps + from celery.bin.call import call from celery.five import WhateverIO -from kombu.utils.json import dumps class test_call: diff --git a/t/unit/bin/test_celery.py b/t/unit/bin/test_celery.py index 71b28a31cbb..33d5ad2acb1 100644 --- a/t/unit/bin/test_celery.py +++ b/t/unit/bin/test_celery.py @@ -4,12 +4,14 @@ import pytest from case import Mock, patch + from celery import __main__ from celery.bin import celery as mod from celery.bin.base import Error -from celery.bin.celery import main as mainfun from celery.bin.celery import (CeleryCommand, Command, determine_exit_status, - help, multi, report) + help) +from celery.bin.celery import main as mainfun +from celery.bin.celery import multi, report from celery.five import WhateverIO from celery.platforms import EX_FAILURE, EX_OK, EX_USAGE diff --git a/t/unit/bin/test_celeryd_detach.py b/t/unit/bin/test_celeryd_detach.py index 5205749f06f..98c0932c6fa 100644 --- a/t/unit/bin/test_celeryd_detach.py +++ b/t/unit/bin/test_celeryd_detach.py @@ -2,6 +2,7 @@ import pytest from case import Mock, mock, patch + from celery.bin.celeryd_detach import detach, detached_celeryd, main from celery.platforms import IS_WINDOWS diff --git a/t/unit/bin/test_celeryevdump.py b/t/unit/bin/test_celeryevdump.py index 7d50ad82f15..f2300e988b9 100644 --- a/t/unit/bin/test_celeryevdump.py +++ b/t/unit/bin/test_celeryevdump.py @@ -3,6 +3,7 @@ from time import time from case import Mock, patch + from celery.events.dumper import Dumper, evdump, humanize_type from celery.five import WhateverIO diff --git a/t/unit/bin/test_control.py b/t/unit/bin/test_control.py index fa173b603cd..067443d3a69 100644 --- a/t/unit/bin/test_control.py +++ b/t/unit/bin/test_control.py @@ -2,6 +2,7 @@ import pytest from case import Mock, patch + from celery.bin.base import Error from celery.bin.control import _RemoteControl, control, inspect, status from celery.five import WhateverIO diff --git a/t/unit/bin/test_events.py b/t/unit/bin/test_events.py index 321ad4fad59..5239dc21966 100644 --- a/t/unit/bin/test_events.py +++ b/t/unit/bin/test_events.py @@ -4,6 +4,7 @@ from functools import wraps from case import patch, skip + from celery.bin import events diff --git a/t/unit/bin/test_list.py b/t/unit/bin/test_list.py index 1dc89e84c62..59c7cad8fc8 100644 --- a/t/unit/bin/test_list.py +++ b/t/unit/bin/test_list.py @@ -2,9 +2,10 @@ import pytest from case import Mock +from kombu.five import WhateverIO + from celery.bin.base import Error from celery.bin.list import list_ -from kombu.five import WhateverIO class test_list: diff --git a/t/unit/bin/test_migrate.py b/t/unit/bin/test_migrate.py index 69033a83d5a..6308bcf454e 100644 --- a/t/unit/bin/test_migrate.py +++ b/t/unit/bin/test_migrate.py @@ -2,6 +2,7 @@ import pytest from case import Mock, patch + from celery.bin.migrate import migrate from celery.five import WhateverIO diff --git a/t/unit/bin/test_multi.py b/t/unit/bin/test_multi.py index 3bb607ada45..6e654faee57 100644 --- a/t/unit/bin/test_multi.py +++ b/t/unit/bin/test_multi.py @@ -5,8 +5,10 @@ import pytest from case import Mock, patch + +from celery.bin.multi import MultiTool from celery.bin.multi import __doc__ as doc -from celery.bin.multi import MultiTool, main +from celery.bin.multi import main from celery.five import WhateverIO diff --git a/t/unit/bin/test_purge.py b/t/unit/bin/test_purge.py index 7b698accf69..143d04eb1fc 100644 --- a/t/unit/bin/test_purge.py +++ b/t/unit/bin/test_purge.py @@ -1,6 +1,7 @@ from __future__ import absolute_import, unicode_literals from case import Mock + from celery.bin.purge import purge from celery.five import WhateverIO diff --git a/t/unit/bin/test_result.py b/t/unit/bin/test_result.py index 238a8187906..db9034ee3d2 100644 --- a/t/unit/bin/test_result.py +++ b/t/unit/bin/test_result.py @@ -1,6 +1,7 @@ from __future__ import absolute_import, unicode_literals from case import patch + from celery.bin.result import result from celery.five import WhateverIO diff --git a/t/unit/bin/test_worker.py b/t/unit/bin/test_worker.py index 4f04777cbfd..03978d0c7db 100644 --- a/t/unit/bin/test_worker.py +++ b/t/unit/bin/test_worker.py @@ -7,6 +7,8 @@ import pytest from billiard.process import current_process from case import Mock, mock, patch, skip +from kombu import Exchange, Queue + from celery import platforms, signals from celery.app import trace from celery.apps import worker as cd @@ -16,7 +18,6 @@ WorkerTerminate) from celery.platforms import EX_FAILURE, EX_OK from celery.worker import state -from kombu import Exchange, Queue @pytest.fixture(autouse=True) diff --git a/t/unit/compat_modules/test_compat.py b/t/unit/compat_modules/test_compat.py index 14746269960..e7fde6deea8 100644 --- a/t/unit/compat_modules/test_compat.py +++ b/t/unit/compat_modules/test_compat.py @@ -3,6 +3,7 @@ from datetime import timedelta import pytest + from celery.five import bytes_if_py2 from celery.schedules import schedule from celery.task import PeriodicTask, periodic_task diff --git a/t/unit/compat_modules/test_compat_utils.py b/t/unit/compat_modules/test_compat_utils.py index 89574bf3b04..adfff21642f 100644 --- a/t/unit/compat_modules/test_compat_utils.py +++ b/t/unit/compat_modules/test_compat_utils.py @@ -1,7 +1,8 @@ from __future__ import absolute_import, unicode_literals -import celery import pytest + +import celery from celery.app.task import Task as ModernTask from celery.task.base import Task as CompatTask diff --git a/t/unit/compat_modules/test_decorators.py b/t/unit/compat_modules/test_decorators.py index 45d5aa138a3..3cbb5cd9828 100644 --- a/t/unit/compat_modules/test_decorators.py +++ b/t/unit/compat_modules/test_decorators.py @@ -3,6 +3,7 @@ import warnings import pytest + from celery.task import base diff --git a/t/unit/compat_modules/test_messaging.py b/t/unit/compat_modules/test_messaging.py index 02951be7cc9..39c3f78e52c 100644 --- a/t/unit/compat_modules/test_messaging.py +++ b/t/unit/compat_modules/test_messaging.py @@ -1,6 +1,7 @@ from __future__ import absolute_import, unicode_literals import pytest + from celery import messaging diff --git a/t/unit/concurrency/test_concurrency.py b/t/unit/concurrency/test_concurrency.py index f1c4ca5d78f..6c4292c67c6 100644 --- a/t/unit/concurrency/test_concurrency.py +++ b/t/unit/concurrency/test_concurrency.py @@ -5,6 +5,7 @@ import pytest from case import Mock, patch + from celery.concurrency.base import BasePool, apply_target from celery.exceptions import WorkerShutdown, WorkerTerminate diff --git a/t/unit/concurrency/test_eventlet.py b/t/unit/concurrency/test_eventlet.py index 088ab83d584..f514fc1e203 100644 --- a/t/unit/concurrency/test_eventlet.py +++ b/t/unit/concurrency/test_eventlet.py @@ -4,6 +4,7 @@ import pytest from case import Mock, patch, skip + from celery.concurrency.eventlet import TaskPool, Timer, apply_target eventlet_modules = ( diff --git a/t/unit/concurrency/test_gevent.py b/t/unit/concurrency/test_gevent.py index 87cad3bf054..7d0334b95fc 100644 --- a/t/unit/concurrency/test_gevent.py +++ b/t/unit/concurrency/test_gevent.py @@ -1,6 +1,7 @@ from __future__ import absolute_import, unicode_literals from case import Mock + from celery.concurrency.gevent import TaskPool, Timer, apply_timeout gevent_modules = ( diff --git a/t/unit/concurrency/test_prefork.py b/t/unit/concurrency/test_prefork.py index 68f4049eefb..1c504e72f63 100644 --- a/t/unit/concurrency/test_prefork.py +++ b/t/unit/concurrency/test_prefork.py @@ -7,6 +7,7 @@ import pytest from case import Mock, mock, patch, skip + from celery.app.defaults import DEFAULTS from celery.five import range from celery.utils.collections import AttributeDict diff --git a/t/unit/conftest.py b/t/unit/conftest.py index ba92eb9e0f7..cd8e8e9b642 100644 --- a/t/unit/conftest.py +++ b/t/unit/conftest.py @@ -10,6 +10,8 @@ import pytest from case import Mock from case.utils import decorator +from kombu import Queue + from celery.backends.cache import CacheBackend, DummyClient # we have to import the pytest plugin fixtures here, # in case user did not do the `python setup.py develop` yet, @@ -19,7 +21,6 @@ from celery.contrib.testing.app import TestApp, Trap from celery.contrib.testing.mocks import (TaskMessage, TaskMessage1, task_message_from_sig) -from kombu import Queue # Tricks flake8 into silencing redefining fixtures warnings. __all__ = ( diff --git a/t/unit/contrib/test_migrate.py b/t/unit/contrib/test_migrate.py index e16434baec2..979c4efb092 100644 --- a/t/unit/contrib/test_migrate.py +++ b/t/unit/contrib/test_migrate.py @@ -5,6 +5,9 @@ import pytest from amqp import ChannelError from case import Mock, mock, patch +from kombu import Connection, Exchange, Producer, Queue +from kombu.transport.virtual import QoS + from celery.contrib.migrate import (State, StopFiltering, _maybe_queue, expand_dest, filter_callback, filter_status, migrate_task, @@ -12,8 +15,6 @@ move_by_taskmap, move_task_by_id, start_filter, task_id_eq, task_id_in) from celery.utils.encoding import bytes_t, ensure_bytes -from kombu import Connection, Exchange, Producer, Queue -from kombu.transport.virtual import QoS # hack to ignore error at shutdown QoS.restore_at_shutdown = False diff --git a/t/unit/contrib/test_rdb.py b/t/unit/contrib/test_rdb.py index 10563eaf3dd..b29fb9be431 100644 --- a/t/unit/contrib/test_rdb.py +++ b/t/unit/contrib/test_rdb.py @@ -5,6 +5,7 @@ import pytest from case import Mock, patch, skip + from celery.contrib.rdb import Rdb, debugger, set_trace from celery.five import WhateverIO diff --git a/t/unit/events/test_events.py b/t/unit/events/test_events.py index de5f4023e2f..29edb09106e 100644 --- a/t/unit/events/test_events.py +++ b/t/unit/events/test_events.py @@ -4,6 +4,7 @@ import pytest from case import Mock, call + from celery.events import Event from celery.events.receiver import CLIENT_CLOCK_SKEW diff --git a/t/unit/events/test_snapshot.py b/t/unit/events/test_snapshot.py index 94436c3854c..25cbee847f0 100644 --- a/t/unit/events/test_snapshot.py +++ b/t/unit/events/test_snapshot.py @@ -2,6 +2,7 @@ import pytest from case import Mock, mock, patch + from celery.app.events import Events from celery.events.snapshot import Polaroid, evcam diff --git a/t/unit/events/test_state.py b/t/unit/events/test_state.py index 835b9fcf01d..4180877bac0 100644 --- a/t/unit/events/test_state.py +++ b/t/unit/events/test_state.py @@ -7,6 +7,7 @@ from time import time from case import Mock, patch, skip + from celery import states, uuid from celery.events import Event from celery.events.state import (HEARTBEAT_DRIFT_MAX, HEARTBEAT_EXPIRE_WINDOW, diff --git a/t/unit/fixups/test_django.py b/t/unit/fixups/test_django.py index 5740793da4c..087d1df8ae3 100644 --- a/t/unit/fixups/test_django.py +++ b/t/unit/fixups/test_django.py @@ -4,6 +4,7 @@ import pytest from case import Mock, mock, patch + from celery.fixups.django import (DjangoFixup, DjangoWorkerFixup, FixupWarning, _maybe_close_fd, fixup) diff --git a/t/unit/security/test_certificate.py b/t/unit/security/test_certificate.py index ef83dd12b92..65a92828167 100644 --- a/t/unit/security/test_certificate.py +++ b/t/unit/security/test_certificate.py @@ -2,6 +2,7 @@ import pytest from case import Mock, mock, patch, skip + from celery.exceptions import SecurityError from celery.security.certificate import Certificate, CertStore, FSCertStore diff --git a/t/unit/security/test_key.py b/t/unit/security/test_key.py index f566a1e73c3..702c3659a74 100644 --- a/t/unit/security/test_key.py +++ b/t/unit/security/test_key.py @@ -1,6 +1,7 @@ from __future__ import absolute_import, unicode_literals import pytest + from celery.exceptions import SecurityError from celery.five import bytes_if_py2 from celery.security.key import PrivateKey diff --git a/t/unit/security/test_security.py b/t/unit/security/test_security.py index 2c0078c6a21..3267436bd47 100644 --- a/t/unit/security/test_security.py +++ b/t/unit/security/test_security.py @@ -16,11 +16,12 @@ import pytest from case import Mock, mock, patch +from kombu.serialization import disable_insecure_serializers, registry + from celery.exceptions import ImproperlyConfigured, SecurityError from celery.five import builtins from celery.security import disable_untrusted_serializers, setup_security from celery.security.utils import reraise_errors -from kombu.serialization import disable_insecure_serializers, registry from .case import SecurityCase diff --git a/t/unit/security/test_serialization.py b/t/unit/security/test_serialization.py index 39eae5fcecf..cb72a2a58fd 100644 --- a/t/unit/security/test_serialization.py +++ b/t/unit/security/test_serialization.py @@ -4,12 +4,13 @@ import os import pytest +from kombu.serialization import registry +from kombu.utils.encoding import bytes_to_str + from celery.exceptions import SecurityError from celery.security.certificate import Certificate, CertStore from celery.security.key import PrivateKey from celery.security.serialization import SecureSerializer, register_auth -from kombu.serialization import registry -from kombu.utils.encoding import bytes_to_str from . import CERT1, CERT2, KEY1, KEY2 from .case import SecurityCase diff --git a/t/unit/tasks/test_canvas.py b/t/unit/tasks/test_canvas.py index f8f2a62687c..2e60932c4b0 100644 --- a/t/unit/tasks/test_canvas.py +++ b/t/unit/tasks/test_canvas.py @@ -4,6 +4,7 @@ import pytest from case import MagicMock, Mock + from celery._state import _task_stack from celery.canvas import (Signature, _chain, _maybe_group, chain, chord, chunks, group, maybe_signature, maybe_unroll_group, diff --git a/t/unit/tasks/test_chord.py b/t/unit/tasks/test_chord.py index 0e661573d80..931a72590d3 100644 --- a/t/unit/tasks/test_chord.py +++ b/t/unit/tasks/test_chord.py @@ -4,6 +4,7 @@ import pytest from case import Mock + from celery import canvas, group, result, uuid from celery.exceptions import ChordError, Retry from celery.five import range diff --git a/t/unit/tasks/test_result.py b/t/unit/tasks/test_result.py index c8be3559fb8..02a23a5bc3e 100644 --- a/t/unit/tasks/test_result.py +++ b/t/unit/tasks/test_result.py @@ -5,6 +5,7 @@ import pytest from case import Mock, call, patch, skip + from celery import states, uuid from celery.backends.base import SyncBackendMixin from celery.exceptions import (CPendingDeprecationWarning, diff --git a/t/unit/tasks/test_states.py b/t/unit/tasks/test_states.py index 88d891e4902..be7df7845b6 100644 --- a/t/unit/tasks/test_states.py +++ b/t/unit/tasks/test_states.py @@ -1,6 +1,7 @@ from __future__ import absolute_import, unicode_literals import pytest + from celery import states diff --git a/t/unit/tasks/test_tasks.py b/t/unit/tasks/test_tasks.py index 7aa14b4dd38..c36576a31f3 100644 --- a/t/unit/tasks/test_tasks.py +++ b/t/unit/tasks/test_tasks.py @@ -6,13 +6,14 @@ import pytest from case import ContextMock, MagicMock, Mock, patch +from kombu import Queue + from celery import Task, group, uuid from celery.app.task import _reprtask from celery.exceptions import Ignore, Retry from celery.five import items, range, string_t from celery.result import EagerResult from celery.utils.time import parse_iso8601 -from kombu import Queue try: from urllib.error import HTTPError diff --git a/t/unit/tasks/test_trace.py b/t/unit/tasks/test_trace.py index 1e11a23890b..3174f203ae6 100644 --- a/t/unit/tasks/test_trace.py +++ b/t/unit/tasks/test_trace.py @@ -2,6 +2,8 @@ import pytest from case import Mock, patch +from kombu.exceptions import EncodeError + from celery import group, signals, states, uuid from celery.app.task import Context from celery.app.trace import (TraceInfo, _fast_trace_task, _trace_task_ret, @@ -12,7 +14,6 @@ reset_worker_optimizations, setup_worker_optimizations, trace_task) from celery.exceptions import Ignore, Reject, Retry -from kombu.exceptions import EncodeError def trace(app, task, args=(), kwargs={}, diff --git a/t/unit/utils/test_collections.py b/t/unit/utils/test_collections.py index 252b99399f1..823d805cb9a 100644 --- a/t/unit/utils/test_collections.py +++ b/t/unit/utils/test_collections.py @@ -7,6 +7,7 @@ import pytest from billiard.einfo import ExceptionInfo from case import skip + from celery.five import items, monotonic from celery.utils.collections import (AttributeDict, BufferMap, ConfigurationView, DictAttribute, diff --git a/t/unit/utils/test_debug.py b/t/unit/utils/test_debug.py index e8f0c10fb9f..9135d1e0fcf 100644 --- a/t/unit/utils/test_debug.py +++ b/t/unit/utils/test_debug.py @@ -2,6 +2,7 @@ import pytest from case import Mock + from celery.utils import debug diff --git a/t/unit/utils/test_deprecated.py b/t/unit/utils/test_deprecated.py index 956aa16eb7c..664c6c6d897 100644 --- a/t/unit/utils/test_deprecated.py +++ b/t/unit/utils/test_deprecated.py @@ -2,6 +2,7 @@ import pytest from case import patch + from celery.utils import deprecated diff --git a/t/unit/utils/test_functional.py b/t/unit/utils/test_functional.py index b83c8a0bad7..f69453db363 100644 --- a/t/unit/utils/test_functional.py +++ b/t/unit/utils/test_functional.py @@ -2,13 +2,14 @@ import pytest from case import skip +from kombu.utils.functional import lazy + from celery.five import nextfun, range from celery.utils.functional import (DummyContext, first, firstmethod, fun_accepts_kwargs, fun_takes_argument, head_from_fun, maybe_list, mlazy, padlist, regen, seq_concat_item, seq_concat_seq) -from kombu.utils.functional import lazy def test_DummyContext(): diff --git a/t/unit/utils/test_graph.py b/t/unit/utils/test_graph.py index ddf1eb0aeeb..cfc7f586776 100644 --- a/t/unit/utils/test_graph.py +++ b/t/unit/utils/test_graph.py @@ -1,6 +1,7 @@ from __future__ import absolute_import, unicode_literals from case import Mock + from celery.five import WhateverIO, items from celery.utils.graph import DependencyGraph diff --git a/t/unit/utils/test_imports.py b/t/unit/utils/test_imports.py index 03d221fb935..f3c6bade4e5 100644 --- a/t/unit/utils/test_imports.py +++ b/t/unit/utils/test_imports.py @@ -2,6 +2,7 @@ import pytest from case import Mock + from celery.five import bytes_if_py2 from celery.utils.imports import (NotAPackage, find_module, gen_task_name, module_file, qualname, reload_from_cwd) diff --git a/t/unit/utils/test_local.py b/t/unit/utils/test_local.py index 6cf4d136e69..ea3730a77f4 100644 --- a/t/unit/utils/test_local.py +++ b/t/unit/utils/test_local.py @@ -4,6 +4,7 @@ import pytest from case import Mock, skip + from celery.five import long_t, python_2_unicode_compatible, string from celery.local import PromiseProxy, Proxy, maybe_evaluate, try_import diff --git a/t/unit/utils/test_nodenames.py b/t/unit/utils/test_nodenames.py index 45156632d27..8a4ae569f3c 100644 --- a/t/unit/utils/test_nodenames.py +++ b/t/unit/utils/test_nodenames.py @@ -1,8 +1,9 @@ from __future__ import absolute_import, unicode_literals -from celery.utils.nodenames import worker_direct from kombu import Queue +from celery.utils.nodenames import worker_direct + class test_worker_direct: diff --git a/t/unit/utils/test_platforms.py b/t/unit/utils/test_platforms.py index 04dfa604255..2192737d4ce 100644 --- a/t/unit/utils/test_platforms.py +++ b/t/unit/utils/test_platforms.py @@ -8,6 +8,7 @@ import pytest from case import Mock, call, mock, patch, skip + from celery import _find_option_with_arg, platforms from celery.exceptions import SecurityError from celery.five import WhateverIO diff --git a/t/unit/utils/test_saferepr.py b/t/unit/utils/test_saferepr.py index 3ace0df3bc0..eea1689a2ee 100644 --- a/t/unit/utils/test_saferepr.py +++ b/t/unit/utils/test_saferepr.py @@ -8,6 +8,7 @@ import pytest from case import skip + from celery.five import (items, long_t, python_2_unicode_compatible, text_t, values) from celery.utils.saferepr import saferepr diff --git a/t/unit/utils/test_serialization.py b/t/unit/utils/test_serialization.py index 8cf62072258..0dd3685f9c3 100644 --- a/t/unit/utils/test_serialization.py +++ b/t/unit/utils/test_serialization.py @@ -6,9 +6,10 @@ import pytest import pytz from case import Mock, mock +from kombu import Queue + from celery.utils.serialization import (UnpickleableExceptionWrapper, get_pickleable_etype, jsonify) -from kombu import Queue class test_AAPickle: diff --git a/t/unit/utils/test_sysinfo.py b/t/unit/utils/test_sysinfo.py index 26ba6327b0b..fe1830d7ccf 100644 --- a/t/unit/utils/test_sysinfo.py +++ b/t/unit/utils/test_sysinfo.py @@ -1,6 +1,7 @@ from __future__ import absolute_import, unicode_literals from case import skip + from celery.utils.sysinfo import df, load_average diff --git a/t/unit/utils/test_term.py b/t/unit/utils/test_term.py index 3e87df2b182..579496c0921 100644 --- a/t/unit/utils/test_term.py +++ b/t/unit/utils/test_term.py @@ -3,6 +3,7 @@ import pytest from case import skip + from celery.five import text_t from celery.utils import term from celery.utils.term import colored, fg diff --git a/t/unit/utils/test_text.py b/t/unit/utils/test_text.py index b7acd625900..f50bfac77f3 100644 --- a/t/unit/utils/test_text.py +++ b/t/unit/utils/test_text.py @@ -1,6 +1,7 @@ from __future__ import absolute_import, unicode_literals import pytest + from celery.utils.text import (abbr, abbrtask, ensure_newlines, indent, pretty, truncate) diff --git a/t/unit/utils/test_threads.py b/t/unit/utils/test_threads.py index 85888e64a99..8aa5cd92575 100644 --- a/t/unit/utils/test_threads.py +++ b/t/unit/utils/test_threads.py @@ -2,6 +2,7 @@ import pytest from case import mock, patch + from celery.utils.threads import (Local, LocalManager, _FastLocalStack, _LocalStack, bgThread) diff --git a/t/unit/utils/test_time.py b/t/unit/utils/test_time.py index 519390138bb..1a294007006 100644 --- a/t/unit/utils/test_time.py +++ b/t/unit/utils/test_time.py @@ -5,6 +5,8 @@ import pytest import pytz from case import Mock, patch +from pytz import AmbiguousTimeError + from celery.utils.iso8601 import parse_iso8601 from celery.utils.time import (LocalTimezone, delta_resolution, ffwd, get_exponential_backoff_interval, @@ -12,7 +14,6 @@ maybe_iso8601, maybe_make_aware, maybe_timedelta, rate, remaining, timezone, utcoffset) -from pytz import AmbiguousTimeError class test_LocalTimezone: diff --git a/t/unit/utils/test_timer2.py b/t/unit/utils/test_timer2.py index ee435443b4f..3ec2b911938 100644 --- a/t/unit/utils/test_timer2.py +++ b/t/unit/utils/test_timer2.py @@ -3,9 +3,10 @@ import sys import time -import celery.utils.timer2 as timer2 from case import Mock, call, patch +import celery.utils.timer2 as timer2 + class test_Timer: diff --git a/t/unit/utils/test_utils.py b/t/unit/utils/test_utils.py index a29e1a34075..de4d2fe3eb6 100644 --- a/t/unit/utils/test_utils.py +++ b/t/unit/utils/test_utils.py @@ -1,6 +1,7 @@ from __future__ import absolute_import, unicode_literals import pytest + from celery.utils import cached_property, chunks diff --git a/t/unit/worker/test_autoscale.py b/t/unit/worker/test_autoscale.py index f4e7949ffae..52ec85887ac 100644 --- a/t/unit/worker/test_autoscale.py +++ b/t/unit/worker/test_autoscale.py @@ -3,6 +3,7 @@ import sys from case import Mock, mock, patch + from celery.concurrency.base import BasePool from celery.five import monotonic from celery.utils.objects import Bunch diff --git a/t/unit/worker/test_bootsteps.py b/t/unit/worker/test_bootsteps.py index 0ef2d1ac6bf..40e6134e206 100644 --- a/t/unit/worker/test_bootsteps.py +++ b/t/unit/worker/test_bootsteps.py @@ -2,6 +2,7 @@ import pytest from case import Mock, patch + from celery import bootsteps diff --git a/t/unit/worker/test_components.py b/t/unit/worker/test_components.py index 1bc35500fac..46867d0585d 100644 --- a/t/unit/worker/test_components.py +++ b/t/unit/worker/test_components.py @@ -2,6 +2,7 @@ import pytest from case import Mock, patch, skip + from celery.exceptions import ImproperlyConfigured from celery.worker.components import Beat, Hub, Pool, Timer diff --git a/t/unit/worker/test_consumer.py b/t/unit/worker/test_consumer.py index a8def7a3b8c..0f8b89cb833 100644 --- a/t/unit/worker/test_consumer.py +++ b/t/unit/worker/test_consumer.py @@ -7,6 +7,7 @@ import pytest from billiard.exceptions import RestartFreqExceeded from case import ContextMock, Mock, call, patch, skip + from celery.utils.collections import LimitedSet from celery.worker.consumer.agent import Agent from celery.worker.consumer.consumer import (CLOSE, TERMINATE, Consumer, diff --git a/t/unit/worker/test_control.py b/t/unit/worker/test_control.py index acdcde157d8..980baca796d 100644 --- a/t/unit/worker/test_control.py +++ b/t/unit/worker/test_control.py @@ -7,17 +7,18 @@ import pytest from case import Mock, call, patch +from kombu import pidbox +from kombu.utils.uuid import uuid + from celery.five import Queue as FastQueue from celery.utils.collections import AttributeDict from celery.utils.timer2 import Timer from celery.worker import WorkController as _WC # noqa -from celery.worker import state as worker_state from celery.worker import consumer, control +from celery.worker import state as worker_state from celery.worker.pidbox import Pidbox, gPidbox from celery.worker.request import Request from celery.worker.state import revoked -from kombu import pidbox -from kombu.utils.uuid import uuid hostname = socket.gethostname() diff --git a/t/unit/worker/test_heartbeat.py b/t/unit/worker/test_heartbeat.py index fc3857c00b8..98853b9090e 100644 --- a/t/unit/worker/test_heartbeat.py +++ b/t/unit/worker/test_heartbeat.py @@ -1,6 +1,7 @@ from __future__ import absolute_import, unicode_literals from case import Mock + from celery.worker.heartbeat import Heart diff --git a/t/unit/worker/test_loops.py b/t/unit/worker/test_loops.py index a2a65698ef4..8dce5f0504f 100644 --- a/t/unit/worker/test_loops.py +++ b/t/unit/worker/test_loops.py @@ -5,6 +5,8 @@ import pytest from case import Mock +from kombu.async import ERR, READ, WRITE, Hub + from celery.bootsteps import CLOSE, RUN from celery.exceptions import (InvalidTaskError, WorkerLostError, WorkerShutdown, WorkerTerminate) @@ -13,7 +15,6 @@ from celery.worker import state from celery.worker.consumer import Consumer from celery.worker.loops import _quick_drain, asynloop, synloop -from kombu.async import ERR, READ, WRITE, Hub @python_2_unicode_compatible diff --git a/t/unit/worker/test_request.py b/t/unit/worker/test_request.py index 136a5e913aa..5491b4c6994 100644 --- a/t/unit/worker/test_request.py +++ b/t/unit/worker/test_request.py @@ -11,6 +11,10 @@ import pytest from billiard.einfo import ExceptionInfo from case import Mock, patch +from kombu.utils.encoding import (default_encode, from_utf8, safe_repr, + safe_str) +from kombu.utils.uuid import uuid + from celery import states from celery.app.trace import (TraceInfo, _trace_task_ret, build_tracer, mro_lookup, reset_worker_optimizations, @@ -20,12 +24,9 @@ from celery.five import monotonic from celery.signals import task_revoked from celery.worker import request as module -from celery.worker.request import logger as req_logger from celery.worker.request import Request, create_request_cls +from celery.worker.request import logger as req_logger from celery.worker.state import revoked -from kombu.utils.encoding import (default_encode, from_utf8, safe_repr, - safe_str) -from kombu.utils.uuid import uuid class RequestCase: diff --git a/t/unit/worker/test_state.py b/t/unit/worker/test_state.py index e8b96894590..f1c737faaa9 100644 --- a/t/unit/worker/test_state.py +++ b/t/unit/worker/test_state.py @@ -5,6 +5,7 @@ import pytest from case import Mock, patch + from celery import uuid from celery.exceptions import WorkerShutdown, WorkerTerminate from celery.utils.collections import LimitedSet diff --git a/t/unit/worker/test_strategy.py b/t/unit/worker/test_strategy.py index 03e266bde5f..7d60c480f6b 100644 --- a/t/unit/worker/test_strategy.py +++ b/t/unit/worker/test_strategy.py @@ -5,6 +5,8 @@ import pytest from case import Mock, patch +from kombu.utils.limits import TokenBucket + from celery import Task from celery.exceptions import InvalidTaskError from celery.utils.time import rate @@ -12,7 +14,6 @@ from celery.worker.request import Request from celery.worker.strategy import default as default_strategy from celery.worker.strategy import proto1_to_proto2 -from kombu.utils.limits import TokenBucket class test_proto1_to_proto2: diff --git a/t/unit/worker/test_worker.py b/t/unit/worker/test_worker.py index b976d6265e9..5b77b460c95 100644 --- a/t/unit/worker/test_worker.py +++ b/t/unit/worker/test_worker.py @@ -11,27 +11,29 @@ import pytest from amqp import ChannelError from case import Mock, patch, skip +from kombu import Connection +from kombu.common import QoS, ignore_errors +from kombu.transport.base import Message +from kombu.transport.memory import Transport +from kombu.utils.uuid import uuid + from celery.bootsteps import CLOSE, RUN, TERMINATE, StartStopStep from celery.concurrency.base import BasePool from celery.exceptions import (ImproperlyConfigured, InvalidTaskError, TaskRevokedError, WorkerShutdown, WorkerTerminate) +from celery.five import Empty from celery.five import Queue as FastQueue -from celery.five import Empty, range +from celery.five import range from celery.platforms import EX_FAILURE from celery.utils.nodenames import worker_direct from celery.utils.serialization import pickle from celery.utils.timer2 import Timer -from celery.worker import worker as worker_module from celery.worker import components, consumer, state +from celery.worker import worker as worker_module from celery.worker.consumer import Consumer from celery.worker.pidbox import gPidbox from celery.worker.request import Request -from kombu import Connection -from kombu.common import QoS, ignore_errors -from kombu.transport.base import Message -from kombu.transport.memory import Transport -from kombu.utils.uuid import uuid def MockStep(step=None): diff --git a/tox.ini b/tox.ini index b9cb58b24b7..10a235fc719 100644 --- a/tox.ini +++ b/tox.ini @@ -24,7 +24,7 @@ deps= linkcheck,apicheck,configcheck: -r{toxinidir}/requirements/docs.txt flake8,flakeplus,pydocstyle: -r{toxinidir}/requirements/pkgutils.txt isort-check: -r{toxinidir}/requirements/test-ci-default.txt - isort-check: isort + isort-check: git+https://github.com/timothycrosley/isort.git sitepackages = False recreate = False commands = @@ -79,4 +79,4 @@ commands = pydocstyle {toxinidir}/celery [testenv:isort-check] -commands = isort -rc -c {toxinidir}/celery {toxinidir}/t +commands = isort --project celery --order-by-type -rc -c {toxinidir}/celery {toxinidir}/t