Ask Solem 8 years ago
parent
commit
5b1efe1fed

+ 1 - 1
celery/app/events.py

@@ -3,7 +3,7 @@ from contextlib import contextmanager
 from kombu.utils.objects import cached_property
 
 
-class Events(object):
+class Events:
     """Implements app.events."""
 
     receiver_cls = 'celery.events.receiver:EventReceiver'

+ 3 - 4
celery/apps/multi.py

@@ -1,5 +1,4 @@
 """Start/stop/manage workers."""
-import errno
 import os
 import shlex
 import signal
@@ -70,7 +69,7 @@ def _kwargs_to_command_line(kwargs):
     }
 
 
-class NamespacedOptionParser(object):
+class NamespacedOptionParser:
 
     def __init__(self, args):
         self.args = args
@@ -122,7 +121,7 @@ class NamespacedOptionParser(object):
         dest[prefix + name] = value
 
 
-class Node(object):
+class Node:
     """Represents a node in a cluster."""
 
     def __init__(self, name,
@@ -259,7 +258,7 @@ def maybe_call(fun, *args, **kwargs):
         fun(*args, **kwargs)
 
 
-class MultiParser(object):
+class MultiParser:
     Node = Node
 
     def __init__(self, cmd='celery worker',

+ 4 - 3
celery/bin/base.py

@@ -16,7 +16,7 @@ from pprint import pformat
 from celery import VERSION_BANNER, Celery, maybe_patch_concurrency
 from celery import signals
 from celery.exceptions import (
-    CDeprecationWarning, CPendingDeprecationWarninga, ImproperlyConfigured,
+    CDeprecationWarning, CPendingDeprecationWarning, ImproperlyConfigured,
 )
 from celery.platforms import EX_FAILURE, EX_OK, EX_USAGE, isatty
 from celery.utils import imports
@@ -473,7 +473,7 @@ class Command:
         if config:
             os.environ['CELERY_CONFIG_MODULE'] = config
 
-        self.initialize_app(app, loader)
+        argv = self.initialize_app(app, loader, argv)
 
         self._handle_user_preload_options(argv)
 
@@ -487,7 +487,7 @@ class Command:
                 sender=self, app=self.app, options=user_options,
             )
 
-    def initialize_app(self, app=None, loader=None):
+    def initialize_app(self, app=None, loader=None, argv=None):
         if self.requires_app:
             if app:
                 self.app = self.find_app(app)
@@ -500,6 +500,7 @@ class Command:
                 self.app = Celery(fixups=[])
             else:
                 self.app = self.get_default_app(app, loader)
+        return argv
 
     def get_default_app(self, app=None, loader=None):
         if self.get_app is not None:

+ 1 - 1
celery/contrib/migrate.py

@@ -241,7 +241,7 @@ def prepare_queues(queues):
     return queues
 
 
-class Filterer(object):
+class Filterer:
 
     def __init__(self, app, conn, filter,
                  limit=None, timeout=1.0,

+ 2 - 2
celery/contrib/testing/app.py

@@ -21,7 +21,7 @@ DEFAULT_TEST_CONFIG = {
 }
 
 
-class Trap(object):
+class Trap:
     """Trap that pretends to be an app but raises an exception instead.
 
     This to protect from code that does not properly pass app instances,
@@ -72,7 +72,7 @@ def set_trap(app):
     prev_tls = _state._tls
     _state.set_default_app(trap)
 
-    class NonTLS(object):
+    class NonTLS:
         current_app = trap
     _state._tls = NonTLS()
 

+ 1 - 1
celery/contrib/testing/manager.py

@@ -30,7 +30,7 @@ def humanize_seconds(secs, prefix='', sep='', now='now', **kwargs):
     return s
 
 
-class ManagerMixin(object):
+class ManagerMixin:
     """Mixin that adds :class:`Manager` capabilities."""
 
     def _init_manager(self,

+ 1 - 1
celery/events/dispatcher.py

@@ -16,7 +16,7 @@ from .event import Event, get_exchange, group_from
 __all__ = ['EventDispatcher']
 
 
-class EventDispatcher(object):
+class EventDispatcher:
     """Dispatches event messages.
 
     Arguments:

+ 1 - 1
celery/local.py

@@ -445,7 +445,7 @@ COMPAT_MODULES = {
 DEPRECATED_ATTRS = set(COMPAT_MODULES['celery'].keys()) | {'subtask'}
 
 
-class class_property(object):
+class class_property:
 
     def __init__(self, getter=None, setter=None):
         if getter is not None and not isinstance(getter, classmethod):

+ 1 - 1
celery/schedules.py

@@ -59,7 +59,7 @@ class ParseException(Exception):
     """Raised by :class:`crontab_parser` when the input can't be parsed."""
 
 
-class BaseSchedule(object):
+class BaseSchedule:
 
     def __init__(self, nowfun=None, app=None):
         self.nowfun = nowfun

+ 1 - 1
celery/utils/dispatch/saferef.py

@@ -200,7 +200,7 @@ class BoundNonDescriptorMethodWeakref(BoundMethodWeakref):  # pragma: no cover
         functions can be stored on an attribute named differenty than the
         function's name, such as in::
 
-            >>> class A(object):
+            >>> class A:
             ...     pass
 
             >>> def foo(self):

+ 1 - 1
celery/worker/consumer/consumer.py

@@ -16,7 +16,7 @@ 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 safe_repr, bytes_t
+from kombu.utils.encoding import safe_repr
 from kombu.utils.limits import TokenBucket
 from vine import ppartial, promise
 

+ 1 - 1
celery/worker/worker.py

@@ -59,7 +59,7 @@ defined in the `task_queues` setting.
 """
 
 
-class WorkController(object):
+class WorkController:
     """Unmanaged worker instance."""
 
     app = None

+ 1 - 1
t/unit/app/test_routes.py

@@ -186,7 +186,7 @@ class test_lookup_route(RouteCase):
             **{self.app.conf.task_default_queue: self.d_queue})
 
 
-class TestRouter(object):
+class TestRouter:
 
     def route_for_task(self, task, args, kwargs):
         if task == 'celery.xaza':

+ 1 - 1
t/unit/apps/test_multi.py

@@ -394,7 +394,7 @@ class test_Cluster:
         nodes = p.getpids('celery worker')
 
     def prepare_pidfile_for_getpids(self, Pidfile):
-        class pids(object):
+        class pids:
 
             def __init__(self, path):
                 self.path = path

+ 1 - 1
t/unit/bin/test_base.py

@@ -8,7 +8,7 @@ from celery.bin.base import (
 )
 
 
-class MyApp(object):
+class MyApp:
     user_options = {'preload': None}
 
 APP = MyApp()  # <-- Used by test_with_custom_app

+ 11 - 11
t/unit/bin/test_celery.py

@@ -108,14 +108,14 @@ class test_Command:
 class test_list:
 
     def test_list_bindings_no_support(self):
-        l = list_(app=self.app, stderr=WhateverIO())
+        l = list_(app=self.app, stderr=io.StringIO())
         management = Mock()
         management.get_bindings.side_effect = NotImplementedError()
         with pytest.raises(Error):
             l.list_bindings(management)
 
     def test_run(self):
-        l = list_(app=self.app, stderr=WhateverIO())
+        l = list_(app=self.app, stderr=io.StringIO())
         l.run('bindings')
 
         with pytest.raises(Error):
@@ -136,7 +136,7 @@ class test_call:
 
     @patch('celery.app.base.Celery.send_task')
     def test_run(self, send_task):
-        a = call(app=self.app, stderr=WhateverIO(), stdout=WhateverIO())
+        a = call(app=self.app, stderr=io.StringIO(), stdout=io.StringIO())
         a.run(self.add.name)
         send_task.assert_called()
 
@@ -161,7 +161,7 @@ class test_call:
 class test_purge:
 
     def test_run(self):
-        out = WhateverIO()
+        out = io.StringIO()
         a = purge(app=self.app, stdout=out)
         a._purge = Mock(name='_purge')
         a._purge.return_value = 0
@@ -191,7 +191,7 @@ class test_result:
 
     def test_run(self):
         with patch('celery.result.AsyncResult.get') as get:
-            out = WhateverIO()
+            out = io.StringIO()
             r = result(app=self.app, stdout=out)
             get.return_value = 'Jerry'
             r.run('id')
@@ -210,7 +210,7 @@ class test_status:
 
     @patch('celery.bin.celery.inspect')
     def test_run(self, inspect_):
-        out, err = WhateverIO(), WhateverIO()
+        out, err = io.StringIO(), io.StringIO()
         ins = inspect_.return_value = Mock()
         ins.run.return_value = []
         s = status(self.app, stdout=out, stderr=err)
@@ -227,8 +227,8 @@ class test_migrate:
 
     @patch('celery.contrib.migrate.migrate_tasks')
     def test_run(self, migrate_tasks):
-        out = WhateverIO()
-        m = migrate(app=self.app, stdout=out, stderr=WhateverIO())
+        out = io.StringIO()
+        m = migrate(app=self.app, stdout=out, stderr=io.StringIO())
         with pytest.raises(TypeError):
             m.run()
         migrate_tasks.assert_not_called()
@@ -246,7 +246,7 @@ class test_migrate:
 class test_report:
 
     def test_run(self):
-        out = WhateverIO()
+        out = io.StringIO()
         r = report(app=self.app, stdout=out)
         assert r.run() == EX_OK
         assert out.getvalue()
@@ -255,7 +255,7 @@ class test_report:
 class test_help:
 
     def test_run(self):
-        out = WhateverIO()
+        out = io.StringIO()
         h = help(app=self.app, stdout=out)
         h.parser = Mock()
         assert h.run() == EX_USAGE
@@ -459,7 +459,7 @@ class test_inspect:
 
     @patch('celery.app.control.Control.inspect')
     def test_run(self, real):
-        out = WhateverIO()
+        out = io.StringIO()
         i = inspect(app=self.app, stdout=out)
         with pytest.raises(Error):
             i.run()

+ 1 - 0
t/unit/bin/test_celeryevdump.py

@@ -7,6 +7,7 @@ from celery.events.dumper import (
     evdump,
 )
 
+
 class test_Dumper:
 
     def setup(self):

+ 1 - 1
t/unit/utils/test_encoding.py

@@ -10,7 +10,7 @@ class test_encoding:
     def test_safe_repr(self):
         assert encoding.safe_repr(object())
 
-        class foo(object):
+        class foo:
             def __repr__(self):
                 raise ValueError('foo')
 

+ 2 - 2
t/unit/utils/test_functional.py

@@ -40,7 +40,7 @@ class test_firstmethod:
 
     def test_handles_lazy(self):
 
-        class A(object):
+        class A:
 
             def __init__(self, value=None):
                 self.value = value
@@ -137,7 +137,7 @@ class test_regen:
 class test_head_from_fun:
 
     def test_from_cls(self):
-        class X(object):
+        class X:
             def __call__(x, y, kwarg=1):  # noqa
                 pass
 

+ 14 - 14
t/unit/utils/test_local.py

@@ -60,7 +60,7 @@ class test_Proxy:
 
     def test_bool(self):
 
-        class X(object):
+        class X:
 
             def __bool__(self):
                 return False
@@ -71,7 +71,7 @@ class test_Proxy:
 
     def test_slots(self):
 
-        class X(object):
+        class X:
             __slots__ = ()
 
         x = Proxy(X)
@@ -81,7 +81,7 @@ class test_Proxy:
     @skip.if_python3()
     def test_unicode(self):
 
-        class X(object):
+        class X:
 
             def __unicode__(self):
                 return 'UNICODE'
@@ -98,7 +98,7 @@ class test_Proxy:
 
     def test_dir(self):
 
-        class X(object):
+        class X:
 
             def __dir__(self):
                 return ['a', 'b', 'c']
@@ -106,7 +106,7 @@ class test_Proxy:
         x = Proxy(lambda: X())
         assert dir(x) == ['a', 'b', 'c']
 
-        class Y(object):
+        class Y:
 
             def __dir__(self):
                 raise RuntimeError()
@@ -115,7 +115,7 @@ class test_Proxy:
 
     def test_getsetdel_attr(self):
 
-        class X(object):
+        class X:
             a = 1
             b = 2
             c = 3
@@ -171,7 +171,7 @@ class test_Proxy:
 
     def test_complex_cast(self):
 
-        class O(object):
+        class O:
 
             def __complex__(self):
                 return complex(10.333)
@@ -181,7 +181,7 @@ class test_Proxy:
 
     def test_index(self):
 
-        class O(object):
+        class O:
 
             def __index__(self):
                 return 1
@@ -191,7 +191,7 @@ class test_Proxy:
 
     def test_coerce(self):
 
-        class O(object):
+        class O:
 
             def __coerce__(self, other):
                 return self, other
@@ -270,7 +270,7 @@ class test_Proxy:
 
     def test_hash(self):
 
-        class X(object):
+        class X:
 
             def __hash__(self):
                 return 1234
@@ -279,7 +279,7 @@ class test_Proxy:
 
     def test_call(self):
 
-        class X(object):
+        class X:
 
             def __call__(self):
                 return 1234
@@ -288,7 +288,7 @@ class test_Proxy:
 
     def test_context(self):
 
-        class X(object):
+        class X:
             entered = exited = False
 
             def __enter__(self):
@@ -307,7 +307,7 @@ class test_Proxy:
 
     def test_reduce(self):
 
-        class X(object):
+        class X:
 
             def __reduce__(self):
                 return 123
@@ -320,7 +320,7 @@ class test_PromiseProxy:
 
     def test_only_evaluated_once(self):
 
-        class X(object):
+        class X:
             attr = 123
             evals = 0
 

+ 1 - 1
t/unit/utils/test_platforms.py

@@ -819,7 +819,7 @@ class test_setgroups:
 
 
 def test_check_privileges():
-    class Obj(object):
+    class Obj:
         fchown = 13
     prev, platforms.os = platforms.os, Obj()
     try: