Jelajahi Sumber

Removes python_2_unicode_compatible

Ask Solem 8 tahun lalu
induk
melakukan
caeb3a137a

+ 1 - 4
celery/app/base.py

@@ -25,9 +25,7 @@ from celery._state import (
     _announce_app_finalized,
 )
 from celery.exceptions import AlwaysEagerIgnored, ImproperlyConfigured
-from celery.five import (
-    UserDict, bytes_if_py2, python_2_unicode_compatible, values,
-)
+from celery.five import UserDict, bytes_if_py2, values
 from celery.loaders import get_loader_cls
 from celery.local import PromiseProxy, maybe_evaluate
 from celery.utils import abstract
@@ -103,7 +101,6 @@ class PendingConfiguration(UserDict, AttributeDictMixin):
         return self.callback(key)
 
 
-@python_2_unicode_compatible
 class Celery:
     """Celery application.
 

+ 1 - 2
celery/app/defaults.py

@@ -7,7 +7,7 @@ import sys
 from collections import deque, namedtuple
 from datetime import timedelta
 
-from celery.five import items, keys, python_2_unicode_compatible, values
+from celery.five import items, keys, values
 from celery.utils.functional import memoize
 from celery.utils.serialization import strtobool
 
@@ -51,7 +51,6 @@ def old_ns(ns):
     return {'{0}_{{0}}'.format(ns)}
 
 
-@python_2_unicode_compatible
 class Option:
     alt = None
     deprecate_by = None

+ 1 - 3
celery/app/task.py

@@ -12,7 +12,7 @@ from celery import states
 from celery._state import _task_stack
 from celery.canvas import signature
 from celery.exceptions import Ignore, MaxRetriesExceededError, Reject, Retry
-from celery.five import class_property, items, python_2_unicode_compatible
+from celery.five import class_property, items
 from celery.result import EagerResult
 from celery.utils import abstract
 from celery.utils.functional import mattrgetter, maybe_list
@@ -59,7 +59,6 @@ def _reprtask(task, fmt=None, flags=None):
     )
 
 
-@python_2_unicode_compatible
 class Context:
     logfile = None
     loglevel = None
@@ -135,7 +134,6 @@ class Context:
 
 
 @abstract.CallableTask.register
-@python_2_unicode_compatible
 class Task:
     """Task base class.
 

+ 0 - 3
celery/backends/database/models.py

@@ -8,14 +8,12 @@ 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']
 
 
-@python_2_unicode_compatible
 class Task(ResultModelBase):
     """Task result/status."""
 
@@ -47,7 +45,6 @@ class Task(ResultModelBase):
         return '<Task {0.task_id} state: {0.status}>'.format(self)
 
 
-@python_2_unicode_compatible
 class TaskSet(ResultModelBase):
     """TaskSet result"""
 

+ 1 - 4
celery/beat.py

@@ -23,9 +23,7 @@ from kombu.utils.functional import maybe_evaluate
 from . import __version__
 from . import platforms
 from . import signals
-from .five import (
-    items, monotonic, python_2_unicode_compatible, reraise, values,
-)
+from .five import items, monotonic, reraise, values
 from .schedules import maybe_schedule, crontab
 from .utils.imports import instantiate
 from .utils.timeutils import humanize_seconds
@@ -50,7 +48,6 @@ class SchedulingError(Exception):
 
 
 @total_ordering
-@python_2_unicode_compatible
 class ScheduleEntry:
     """An entry in the scheduler.
 

+ 1 - 4
celery/bin/base.py

@@ -19,9 +19,7 @@ from pprint import pformat
 from celery import VERSION_BANNER, Celery, maybe_patch_concurrency
 from celery import signals
 from celery.exceptions import CDeprecationWarning, CPendingDeprecationWarning
-from celery.five import (
-    getfullargspec, items, python_2_unicode_compatible, string, string_t,
-)
+from celery.five import getfullargspec, items, string, string_t
 from celery.platforms import EX_FAILURE, EX_OK, EX_USAGE
 from celery.utils import term
 from celery.utils import text
@@ -53,7 +51,6 @@ find_rst_ref = re.compile(r':\w+:`(.+?)`')
 find_rst_decl = re.compile(r'^\s*\.\. .+?::.+$')
 
 
-@python_2_unicode_compatible
 class Error(Exception):
     status = EX_FAILURE
 

+ 1 - 2
celery/bin/graph.py

@@ -7,7 +7,7 @@ from __future__ import absolute_import, unicode_literals
 
 from operator import itemgetter
 
-from celery.five import items, python_2_unicode_compatible
+from celery.five import items
 from celery.utils.graph import DependencyGraph, GraphFormatter
 
 from .base import Command
@@ -55,7 +55,6 @@ class graph(Command):
             return '{0} ({1}://)'.format(type(node).__name__,
                                          node._label.split('://')[0])
 
-        @python_2_unicode_compatible
         class Node:
             force_label = None
             scheme = {}

+ 0 - 7
celery/canvas.py

@@ -19,7 +19,6 @@ from kombu.utils import cached_property, fxrange, reprcall, 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
@@ -117,7 +116,6 @@ def _upgrade(fields, sig):
 
 
 @abstract.CallableSignature.register
-@python_2_unicode_compatible
 class Signature(dict):
     """Class that wraps the arguments and execution options
     for a single task invocation.
@@ -503,7 +501,6 @@ class Signature(dict):
 
 
 @Signature.register_type
-@python_2_unicode_compatible
 class chain(Signature):
     """Chains tasks together, so that each tasks follows each other
     by being applied as a callback of the previous task.
@@ -768,7 +765,6 @@ class _basemap(Signature):
 
 
 @Signature.register_type
-@python_2_unicode_compatible
 class xmap(_basemap):
     _task_name = 'celery.map'
 
@@ -779,7 +775,6 @@ class xmap(_basemap):
 
 
 @Signature.register_type
-@python_2_unicode_compatible
 class xstarmap(_basemap):
     _task_name = 'celery.starmap'
 
@@ -842,7 +837,6 @@ def _maybe_group(tasks, app):
 
 
 @Signature.register_type
-@python_2_unicode_compatible
 class group(Signature):
     """Creates a group of tasks to be executed in parallel.
 
@@ -1068,7 +1062,6 @@ class group(Signature):
 
 
 @Signature.register_type
-@python_2_unicode_compatible
 class chord(Signature):
     """Barrier synchronization primitive.
 

+ 1 - 2
celery/contrib/migrate.py

@@ -12,7 +12,7 @@ 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.five import string, string_t
 from celery.utils.nodenames import worker_direct
 
 __all__ = [
@@ -32,7 +32,6 @@ class StopFiltering(Exception):
     pass
 
 
-@python_2_unicode_compatible
 class State:
     count = 0
     filtered = 0

+ 1 - 3
celery/events/state.py

@@ -31,7 +31,7 @@ from kombu.clocks import timetuple
 from kombu.utils import cached_property
 
 from celery import states
-from celery.five import items, python_2_unicode_compatible, values
+from celery.five import items, values
 from celery.utils.functional import LRUCache, memoize, pass1
 from celery.utils.log import get_logger
 
@@ -145,7 +145,6 @@ def with_unique_field(attr):
 
 
 @with_unique_field('hostname')
-@python_2_unicode_compatible
 class Worker:
     """Worker State."""
     heartbeat_max = 4
@@ -238,7 +237,6 @@ class Worker:
 
 
 @with_unique_field('uuid')
-@python_2_unicode_compatible
 class Task:
     """Task State."""
     name = received = sent = started = succeeded = failed = retried = \

+ 1 - 4
celery/exceptions.py

@@ -4,7 +4,7 @@ from __future__ import absolute_import, unicode_literals
 
 import numbers
 
-from .five import python_2_unicode_compatible, string_t
+from .five import string_t
 
 from billiard.exceptions import (  # noqa
     SoftTimeLimitExceeded, TimeLimitExceeded, WorkerLostError, Terminated,
@@ -48,7 +48,6 @@ class TaskPredicate(CeleryError):
     pass
 
 
-@python_2_unicode_compatible
 class Retry(TaskPredicate):
     """The task is to be retried later."""
 
@@ -93,7 +92,6 @@ class Ignore(TaskPredicate):
     """A task can raise this to ignore doing state updates."""
 
 
-@python_2_unicode_compatible
 class Reject(TaskPredicate):
     """A task can raise this if it wants to reject/re-queue the message."""
 
@@ -123,7 +121,6 @@ class ImproperlyConfigured(ImportError):
     """Celery is somehow improperly configured."""
 
 
-@python_2_unicode_compatible
 class NotRegistered(KeyError, CeleryError):
     """The task is not registered."""
 

+ 1 - 7
celery/result.py

@@ -16,9 +16,7 @@ from . import states
 from ._state import _set_task_join_will_block, task_join_will_block
 from .app import app_or_default
 from .exceptions import ImproperlyConfigured, IncompleteStream, TimeoutError
-from .five import (
-    items, python_2_unicode_compatible, range, string_t, monotonic,
-)
+from .five import items, range, string_t, monotonic
 from .utils import deprecated
 from .utils.graph import DependencyGraph, GraphFormatter
 
@@ -62,7 +60,6 @@ class ResultBase:
 
 
 @Thenable.register
-@python_2_unicode_compatible
 class AsyncResult(ResultBase):
     """Query task state.
 
@@ -433,7 +430,6 @@ class AsyncResult(ResultBase):
 
 
 @Thenable.register
-@python_2_unicode_compatible
 class ResultSet(ResultBase):
     """Working with more than one result.
 
@@ -786,7 +782,6 @@ class ResultSet(ResultBase):
 
 
 @Thenable.register
-@python_2_unicode_compatible
 class GroupResult(ResultSet):
     """Like :class:`ResultSet`, but with an associated id.
 
@@ -863,7 +858,6 @@ class GroupResult(ResultSet):
 
 
 @Thenable.register
-@python_2_unicode_compatible
 class EagerResult(AsyncResult):
     """Result that we know has already been executed."""
 

+ 1 - 4
celery/schedules.py

@@ -12,7 +12,7 @@ from datetime import datetime, timedelta
 from kombu.utils import cached_property
 
 from . import current_app
-from .five import python_2_unicode_compatible, range, string_t
+from .five import range, string_t
 from .utils.collections import AttributeDict
 from .utils.timeutils import (
     weekday, maybe_timedelta, remaining, humanize_seconds,
@@ -62,7 +62,6 @@ class ParseException(Exception):
     """Raised by :class:`crontab_parser` when the input can't be parsed."""
 
 
-@python_2_unicode_compatible
 class schedule:
     """Schedule for periodic task.
 
@@ -294,7 +293,6 @@ class crontab_parser:
         return i
 
 
-@python_2_unicode_compatible
 class crontab(schedule):
     """A Crontab can be used as the ``run_every`` value of a
     periodic task entry to add :manpage:`crontab(5)`-like scheduling.
@@ -616,7 +614,6 @@ def maybe_schedule(s, relative=False, app=None):
     return s
 
 
-@python_2_unicode_compatible
 class solar(schedule):
     """A solar event can be used as the ``run_every`` value of a
     periodic task entry to schedule based on certain solar events.

+ 1 - 6
celery/task/base.py

@@ -12,10 +12,7 @@ from kombu import Exchange
 
 from celery import current_app
 from celery.app.task import Context, Task as BaseTask, _reprtask
-from celery.five import (
-    class_property, reclassmethod,
-    python_2_unicode_compatible, with_metaclass,
-)
+from celery.five import class_property, reclassmethod, with_metaclass
 from celery.local import Proxy
 from celery.schedules import maybe_schedule
 from celery.utils.log import get_task_logger
@@ -30,7 +27,6 @@ _COMPAT_CLASSMETHODS = (
 )
 
 
-@python_2_unicode_compatible
 class _CompatShared:
 
     def __init__(self, name, cons):
@@ -124,7 +120,6 @@ class TaskType(type):
 
 
 @with_metaclass(TaskType)
-@python_2_unicode_compatible
 class Task(BaseTask):
     """Deprecated Task base class.
 

+ 0 - 2
celery/tests/app/test_log.py

@@ -10,7 +10,6 @@ from tempfile import mktemp
 from celery import signals
 from celery import uuid
 from celery.app.log import TaskFormatter
-from celery.five import python_2_unicode_compatible
 from celery.utils.log import LoggingProxy
 from celery.utils.log import (
     get_logger,
@@ -135,7 +134,6 @@ class test_ColorFormatter(AppCase):
                 safe_str.side_effect = None
         safe_str.side_effect = on_safe_str
 
-        @python_2_unicode_compatible
         class Record:
             levelname = 'ERROR'
             msg = 'HELLO'

+ 1 - 2
celery/tests/utils/test_local.py

@@ -2,7 +2,7 @@ from __future__ import absolute_import, unicode_literals
 
 import sys
 
-from celery.five import python_2_unicode_compatible, string, long_t
+from celery.five import string, long_t
 from celery.local import (
     Proxy,
     PromiseProxy,
@@ -84,7 +84,6 @@ class test_Proxy(Case):
     @skip.if_python3()
     def test_unicode(self):
 
-        @python_2_unicode_compatible
         class X:
 
             def __unicode__(self):

+ 1 - 8
celery/tests/utils/test_saferepr.py

@@ -5,9 +5,7 @@ import re
 from decimal import Decimal
 from pprint import pprint
 
-from celery.five import (
-    items, long_t, python_2_unicode_compatible, text_t, values,
-)
+from celery.five import items, long_t, text_t, values
 
 from celery.utils.saferepr import saferepr
 
@@ -75,7 +73,6 @@ class list2(list):
     pass
 
 
-@python_2_unicode_compatible
 class list3(list):
 
     def __repr__(self):
@@ -86,7 +83,6 @@ class tuple2(tuple):
     pass
 
 
-@python_2_unicode_compatible
 class tuple3(tuple):
 
     def __repr__(self):
@@ -97,7 +93,6 @@ class set2(set):
     pass
 
 
-@python_2_unicode_compatible
 class set3(set):
 
     def __repr__(self):
@@ -108,7 +103,6 @@ class frozenset2(frozenset):
     pass
 
 
-@python_2_unicode_compatible
 class frozenset3(frozenset):
 
     def __repr__(self):
@@ -119,7 +113,6 @@ class dict2(dict):
     pass
 
 
-@python_2_unicode_compatible
 class dict3(dict):
 
     def __repr__(self):

+ 1 - 2
celery/tests/worker/test_loops.py

@@ -9,7 +9,7 @@ from celery.bootsteps import CLOSE, RUN
 from celery.exceptions import (
     InvalidTaskError, WorkerLostError, WorkerShutdown, WorkerTerminate,
 )
-from celery.five import Empty, python_2_unicode_compatible
+from celery.five import Empty
 from celery.platforms import EX_FAILURE
 from celery.worker import state
 from celery.worker.consumer import Consumer
@@ -18,7 +18,6 @@ from celery.worker.loops import _quick_drain, asynloop, synloop
 from celery.tests.case import AppCase, Mock, task_message_from_sig
 
 
-@python_2_unicode_compatible
 class PromiseEqual:
 
     def __init__(self, fun, *args, **kwargs):

+ 1 - 5
celery/utils/collections.py

@@ -12,7 +12,7 @@ from collections import (
 from heapq import heapify, heappush, heappop
 from itertools import chain, count
 
-from celery.five import Empty, items, keys, python_2_unicode_compatible, values
+from celery.five import Empty, items, keys, values
 
 from .functional import first, uniq
 from .text import match_case
@@ -337,7 +337,6 @@ class ChainMap(MutableMapping):
             return list(self._iterate_values())
 
 
-@python_2_unicode_compatible
 class ConfigurationView(ChainMap, AttributeDictMixin):
     """A view over an applications configuration dictionaries.
 
@@ -416,7 +415,6 @@ class ConfigurationView(ChainMap, AttributeDictMixin):
         )
 
 
-@python_2_unicode_compatible
 class LimitedSet:
     """Kind-of Set (or priority queue) with limitations.
 
@@ -656,7 +654,6 @@ class Evictable:
             raise IndexError()
 
 
-@python_2_unicode_compatible
 class Messagebuffer(Evictable):
 
     Empty = Empty
@@ -718,7 +715,6 @@ class Messagebuffer(Evictable):
 Sequence.register(Messagebuffer)
 
 
-@python_2_unicode_compatible
 class BufferMap(OrderedDict, Evictable):
 
     Buffer = Messagebuffer

+ 0 - 3
celery/utils/dispatch/saferef.py

@@ -10,8 +10,6 @@ import sys
 import traceback
 import weakref
 
-from celery.five import python_2_unicode_compatible
-
 __all__ = ['safe_ref']
 
 PY3 = sys.version_info[0] == 3
@@ -44,7 +42,6 @@ def safe_ref(target, on_delete=None):  # pragma: no cover
         return weakref.ref(target)
 
 
-@python_2_unicode_compatible
 class BoundMethodWeakref:  # pragma: no cover
     """'Safe' and reusable weak references to instance methods.
 

+ 1 - 2
celery/utils/dispatch/signal.py

@@ -4,7 +4,7 @@ from __future__ import absolute_import, unicode_literals
 
 import weakref
 
-from celery.five import python_2_unicode_compatible, range, text_t
+from celery.five import range, text_t
 from celery.local import PromiseProxy, Proxy
 from celery.utils.log import get_logger
 
@@ -28,7 +28,6 @@ def _make_id(target):  # pragma: no cover
     return id(target)
 
 
-@python_2_unicode_compatible
 class Signal:  # pragma: no cover
     """Observer pattern implementation.
 

+ 1 - 2
celery/utils/graph.py

@@ -7,7 +7,7 @@ from textwrap import dedent
 
 from kombu.utils.encoding import safe_str, bytes_to_str
 
-from celery.five import items, python_2_unicode_compatible
+from celery.five import items
 
 __all__ = ['DOT', 'CycleError', 'DependencyGraph', 'GraphFormatter']
 
@@ -29,7 +29,6 @@ class CycleError(Exception):
     """A cycle was detected in an acyclic graph."""
 
 
-@python_2_unicode_compatible
 class DependencyGraph:
     """A directed acyclic graph of objects and their dependencies.
 

+ 1 - 4
celery/utils/serialization.py

@@ -13,9 +13,7 @@ from itertools import takewhile
 
 from kombu.utils.encoding import bytes_to_str, str_to_bytes
 
-from celery.five import (
-    bytes_if_py2, python_2_unicode_compatible, items, reraise, string_t,
-)
+from celery.five import bytes_if_py2, items, reraise, string_t
 
 from .encoding import safe_repr
 
@@ -80,7 +78,6 @@ def create_exception_cls(name, module, parent=None):
     return subclass_exception(name, parent, module)
 
 
-@python_2_unicode_compatible
 class UnpickleableExceptionWrapper(Exception):
     """Wraps unpickleable exceptions.
 

+ 1 - 2
celery/utils/term.py

@@ -6,7 +6,7 @@ import platform
 
 from functools import reduce
 
-from celery.five import python_2_unicode_compatible, string
+from celery.five import string
 
 __all__ = ['colored']
 
@@ -22,7 +22,6 @@ def fg(s):
     return COLOR_SEQ % s
 
 
-@python_2_unicode_compatible
 class colored:
     """Terminal colored text.
 

+ 1 - 2
celery/utils/threads.py

@@ -11,7 +11,7 @@ import traceback
 from contextlib import contextmanager
 
 from celery.local import Proxy
-from celery.five import THREAD_TIMEOUT_MAX, items, python_2_unicode_compatible
+from celery.five import THREAD_TIMEOUT_MAX, items
 
 try:
     from greenlet import getcurrent as get_ident
@@ -243,7 +243,6 @@ class _LocalStack:
             return None
 
 
-@python_2_unicode_compatible
 class LocalManager:
     """Local objects cannot manage themselves. For that you need a local
     manager.  You can pass a local manager multiple locals or add them

+ 1 - 3
celery/utils/timeutils.py

@@ -14,7 +14,7 @@ from kombu.utils import cached_property, reprcall
 
 from pytz import timezone as _timezone, AmbiguousTimeError, FixedOffset
 
-from celery.five import python_2_unicode_compatible, string_t
+from celery.five import string_t
 
 from .functional import dictfilter
 from .iso8601 import parse_iso8601
@@ -54,7 +54,6 @@ ZERO = timedelta(0)
 _local_timezone = None
 
 
-@python_2_unicode_compatible
 class LocalTimezone(tzinfo):
     """Local time implementation taken from Python's docs.
 
@@ -323,7 +322,6 @@ def maybe_make_aware(dt, tz=None):
     )
 
 
-@python_2_unicode_compatible
 class ffwd:
     """Version of ``dateutil.relativedelta`` that only supports addition."""
 

+ 1 - 2
celery/worker/__init__.py

@@ -33,7 +33,7 @@ from celery import signals
 from celery.exceptions import (
     ImproperlyConfigured, WorkerTerminate, TaskRevokedError,
 )
-from celery.five import python_2_unicode_compatible, values
+from celery.five import values
 from celery.platforms import EX_FAILURE, create_pidlock
 from celery.utils.imports import reload_from_cwd
 from celery.utils.log import mlevel, worker_logger as logger
@@ -62,7 +62,6 @@ defined in the `task_queues` setting.
 """
 
 
-@python_2_unicode_compatible
 class WorkController:
     """Unmanaged worker instance."""
 

+ 3 - 4
celery/worker/consumer/consumer.py

@@ -26,7 +26,7 @@ from celery import bootsteps
 from celery import signals
 from celery.app.trace import build_tracer
 from celery.exceptions import InvalidTaskError, NotRegistered
-from celery.five import buffer_t, items, python_2_unicode_compatible, values
+from celery.five import buffer_t, items, values
 from celery.utils.functional import noop
 from celery.utils.log import get_logger
 from celery.utils.nodenames import gethostname
@@ -113,11 +113,10 @@ def dump_body(m, body):
     body = m.body if body is None else body
     if isinstance(body, buffer_t):
         body = bytes_t(body)
-    return '{0} ({1}b)'.format(truncate(safe_repr(body), 1024),
-                               len(m.body))
+    return '{0} ({1}b)'.format(
+        truncate(safe_repr(body), 1024), len(m.body))
 
 
-@python_2_unicode_compatible
 class Consumer:
 
     Strategies = dict

+ 1 - 2
celery/worker/request.py

@@ -20,7 +20,7 @@ from celery.exceptions import (
     SoftTimeLimitExceeded, TimeLimitExceeded,
     WorkerLostError, Terminated, Retry, Reject,
 )
-from celery.five import python_2_unicode_compatible, string
+from celery.five import string
 from celery.platforms import signals as _signals
 from celery.utils.functional import noop
 from celery.utils.log import get_logger
@@ -58,7 +58,6 @@ task_ready = state.task_ready
 revoked_tasks = state.revoked
 
 
-@python_2_unicode_compatible
 class Request:
     """A request for task execution."""
     acknowledged = False