Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 27, 2021
1 parent de4be1a commit a061976
Show file tree
Hide file tree
Showing 23 changed files with 48 additions and 53 deletions.
6 changes: 3 additions & 3 deletions celery/app/amqp.py
Expand Up @@ -56,7 +56,7 @@ class Queues(dict):
def __init__(self, queues=None, default_exchange=None,
create_missing=True, autoexchange=None,
max_priority=None, default_routing_key=None):
dict.__init__(self)
super().__init__()
self.aliases = WeakValueDictionary()
self.default_exchange = default_exchange
self.default_routing_key = default_routing_key
Expand All @@ -73,12 +73,12 @@ def __getitem__(self, name):
try:
return self.aliases[name]
except KeyError:
return dict.__getitem__(self, name)
return super().__getitem__(name)

def __setitem__(self, name, queue):
if self.default_exchange and not queue.exchange:
queue.exchange = self.default_exchange
dict.__setitem__(self, name, queue)
super().__setitem__(name, queue)
if queue.alias:
self.aliases[queue.alias] = queue

Expand Down
2 changes: 1 addition & 1 deletion celery/app/log.py
Expand Up @@ -41,7 +41,7 @@ def format(self, record):
else:
record.__dict__.setdefault('task_name', '???')
record.__dict__.setdefault('task_id', '???')
return ColorFormatter.format(self, record)
return super().format(record)


class Logging:
Expand Down
2 changes: 1 addition & 1 deletion celery/apps/worker.py
Expand Up @@ -121,7 +121,7 @@ def on_init_blueprint(self):

def on_start(self):
app = self.app
WorkController.on_start(self)
super().on_start()

# this signal can be used to, for example, change queues after
# the -Q option has been applied.
Expand Down
12 changes: 6 additions & 6 deletions celery/backends/elasticsearch.py
Expand Up @@ -199,10 +199,10 @@ def _update(self, id, body, state, **kwargs):

def encode(self, data):
if self.es_save_meta_as_text:
return KeyValueStoreBackend.encode(self, data)
return super().encode(data)
else:
if not isinstance(data, dict):
return KeyValueStoreBackend.encode(self, data)
return super().encode(data)
if data.get("result"):
data["result"] = self._encode(data["result"])[2]
if data.get("traceback"):
Expand All @@ -211,14 +211,14 @@ def encode(self, data):

def decode(self, payload):
if self.es_save_meta_as_text:
return KeyValueStoreBackend.decode(self, payload)
return super().decode(payload)
else:
if not isinstance(payload, dict):
return KeyValueStoreBackend.decode(self, payload)
return super().decode(payload)
if payload.get("result"):
payload["result"] = KeyValueStoreBackend.decode(self, payload["result"])
payload["result"] = super().decode(payload["result"])
if payload.get("traceback"):
payload["traceback"] = KeyValueStoreBackend.decode(self, payload["traceback"])
payload["traceback"] = super().decode(payload["traceback"])
return payload

def mget(self, keys):
Expand Down
2 changes: 1 addition & 1 deletion celery/beat.py
Expand Up @@ -512,7 +512,7 @@ class PersistentScheduler(Scheduler):

def __init__(self, *args, **kwargs):
self.schedule_filename = kwargs.get('schedule_filename')
Scheduler.__init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)

def _remove_db(self):
for suffix in self.known_suffixes:
Expand Down
21 changes: 8 additions & 13 deletions celery/canvas.py
Expand Up @@ -485,7 +485,7 @@ def __repr__(self):
return self.reprcall()

def items(self):
for k, v in dict.items(self):
for k, v in super().items():
yield k.decode() if isinstance(k, bytes) else k, v

@property
Expand Down Expand Up @@ -600,8 +600,7 @@ def from_dict(cls, d, app=None):
def __init__(self, *tasks, **options):
tasks = (regen(tasks[0]) if len(tasks) == 1 and is_list(tasks[0])
else tasks)
Signature.__init__(
self, 'celery.chain', (), {'tasks': tasks}, **options
super().__init__('celery.chain', (), {'tasks': tasks}, **options
)
self._use_link = options.pop('use_link', None)
self.subtask_type = 'chain'
Expand All @@ -613,7 +612,7 @@ def __call__(self, *args, **kwargs):

def clone(self, *args, **kwargs):
to_signature = maybe_signature
signature = Signature.clone(self, *args, **kwargs)
signature = super().clone(*args, **kwargs)
signature.kwargs['tasks'] = [
to_signature(sig, app=self._app, clone=True)
for sig in signature.kwargs['tasks']
Expand Down Expand Up @@ -903,8 +902,7 @@ def from_dict(cls, d, app=None):
return cls(*cls._unpack_args(d['kwargs']), app=app, **d['options'])

def __init__(self, task, it, **options):
Signature.__init__(
self, self._task_name, (),
super().__init__(self._task_name, (),
{'task': task, 'it': regen(it)}, immutable=True, **options
)

Expand Down Expand Up @@ -957,8 +955,7 @@ def from_dict(cls, d, app=None):
return chunks(*cls._unpack_args(d['kwargs']), app=app, **d['options'])

def __init__(self, task, it, n, **options):
Signature.__init__(
self, 'celery.chunks', (),
super().__init__('celery.chunks', (),
{'task': task, 'it': regen(it), 'n': n},
immutable=True, **options
)
Expand Down Expand Up @@ -1056,8 +1053,7 @@ def __init__(self, *tasks, **options):
tasks = [tasks.clone()]
if not isinstance(tasks, _regen):
tasks = regen(tasks)
Signature.__init__(
self, 'celery.group', (), {'tasks': tasks}, **options
super().__init__('celery.group', (), {'tasks': tasks}, **options
)
self.subtask_type = 'group'

Expand Down Expand Up @@ -1353,8 +1349,7 @@ def __init__(self, header, body=None, task='celery.chord',
args=None, kwargs=None, app=None, **options):
args = args if args else ()
kwargs = kwargs if kwargs else {'kwargs': {}}
Signature.__init__(
self, task, args,
super().__init__(task, args,
{**kwargs, 'header': _maybe_group(header, app),
'body': maybe_signature(body, app=app)}, app=app, **options
)
Expand Down Expand Up @@ -1500,7 +1495,7 @@ def run(self, header, body, partial_args, app=None, interval=None,
return bodyres

def clone(self, *args, **kwargs):
signature = Signature.clone(self, *args, **kwargs)
signature = super().clone(*args, **kwargs)
# need to make copy of body
try:
signature.kwargs['body'] = maybe_signature(
Expand Down
2 changes: 1 addition & 1 deletion celery/contrib/rdb.py
Expand Up @@ -110,7 +110,7 @@ def __init__(self, host=CELERY_RDB_HOST, port=CELERY_RDB_PORT,
self.remote_addr = ':'.join(str(v) for v in address)
self.say(SESSION_STARTED.format(self=self))
self._handle = sys.stdin = sys.stdout = self._client.makefile('rw')
Pdb.__init__(self, completekey='tab',
super().__init__(completekey='tab',
stdin=self._handle, stdout=self._handle)

def get_avail_port(self, host, port, search_limit=100, skew=+0):
Expand Down
2 changes: 1 addition & 1 deletion celery/events/cursesmon.py
Expand Up @@ -483,7 +483,7 @@ class DisplayThread(threading.Thread): # pragma: no cover
def __init__(self, display):
self.display = display
self.shutdown = False
threading.Thread.__init__(self)
super().__init__()

def run(self):
while not self.shutdown:
Expand Down
4 changes: 2 additions & 2 deletions celery/result.py
Expand Up @@ -884,11 +884,11 @@ class GroupResult(ResultSet):
def __init__(self, id=None, results=None, parent=None, **kwargs):
self.id = id
self.parent = parent
ResultSet.__init__(self, results, **kwargs)
super().__init__(results, **kwargs)

def _on_ready(self):
self.backend.remove_pending_result(self)
ResultSet._on_ready(self)
super()._on_ready()

def save(self, backend=None):
"""Save group-result for later retrieval using :meth:`restore`.
Expand Down
2 changes: 1 addition & 1 deletion celery/security/certificate.py
Expand Up @@ -85,7 +85,7 @@ class FSCertStore(CertStore):
"""File system certificate store."""

def __init__(self, path):
CertStore.__init__(self)
super().__init__()
if os.path.isdir(path):
path = os.path.join(path, '*')
for p in glob.glob(path):
Expand Down
8 changes: 4 additions & 4 deletions celery/utils/log.py
Expand Up @@ -133,17 +133,17 @@ class ColorFormatter(logging.Formatter):
}

def __init__(self, fmt=None, use_color=True):
logging.Formatter.__init__(self, fmt)
super().__init__(fmt)
self.use_color = use_color

def formatException(self, ei):
if ei and not isinstance(ei, tuple):
ei = sys.exc_info()
r = logging.Formatter.formatException(self, ei)
r = super().formatException(ei)
return r

def format(self, record):
msg = logging.Formatter.format(self, record)
msg = super().format(record)
color = self.colors.get(record.levelname)

# reset exception info later for other handlers...
Expand All @@ -168,7 +168,7 @@ def format(self, record):
),
)
try:
return logging.Formatter.format(self, record)
return super().format(record)
finally:
record.msg, record.exc_info = prev_msg, einfo
else:
Expand Down
2 changes: 1 addition & 1 deletion celery/utils/serialization.py
Expand Up @@ -133,7 +133,7 @@ def __init__(self, exc_module, exc_cls_name, exc_args, text=None):
self.exc_cls_name = exc_cls_name
self.exc_args = safe_exc_args
self.text = text
Exception.__init__(self, exc_module, exc_cls_name, safe_exc_args,
super().__init__(exc_module, exc_cls_name, safe_exc_args,
text)

def restore(self):
Expand Down
2 changes: 1 addition & 1 deletion celery/utils/time.py
Expand Up @@ -66,7 +66,7 @@ def __init__(self):
else:
self.DSTOFFSET = self.STDOFFSET
self.DSTDIFF = self.DSTOFFSET - self.STDOFFSET
tzinfo.__init__(self)
super().__init__()

def __repr__(self):
return f'<LocalTimezone: UTC{int(self.DSTOFFSET.total_seconds() / 3600):+03d}>'
Expand Down
2 changes: 1 addition & 1 deletion celery/utils/timer2.py
Expand Up @@ -48,7 +48,7 @@ def __init__(self, schedule=None, on_error=None, on_tick=None,
max_interval=max_interval)
self.on_start = on_start
self.on_tick = on_tick or self.on_tick
threading.Thread.__init__(self)
super().__init__()
# `_is_stopped` is likely to be an attribute on `Thread` objects so we
# double underscore these names to avoid shadowing anything and
# potentially getting confused by the superclass turning these into
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -139,7 +139,7 @@ class pytest(setuptools.command.test.test):
user_options = [('pytest-args=', 'a', 'Arguments to pass to pytest')]

def initialize_options(self):
setuptools.command.test.test.initialize_options(self)
super().initialize_options()
self.pytest_args = []

def run_tests(self):
Expand Down
4 changes: 2 additions & 2 deletions t/unit/app/test_beat.py
Expand Up @@ -127,7 +127,7 @@ class mScheduler(beat.Scheduler):

def __init__(self, *args, **kwargs):
self.sent = []
beat.Scheduler.__init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)

def send_task(self, name=None, args=None, kwargs=None, **options):
self.sent.append({'name': name,
Expand Down Expand Up @@ -599,7 +599,7 @@ class MockPersistentScheduler(beat.PersistentScheduler):

def __init__(self, *args, **kwargs):
self.sent = []
beat.PersistentScheduler.__init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)

def send_task(self, task=None, args=None, kwargs=None, **options):
self.sent.append({'task': task,
Expand Down
6 changes: 3 additions & 3 deletions t/unit/app/test_builtins.py
Expand Up @@ -98,7 +98,7 @@ def setup(self):
)
self.app.conf.task_always_eager = True
self.task = builtins.add_group_task(self.app)
BuiltinsCase.setup(self)
super().setup()

def test_apply_async_eager(self):
self.task.apply = Mock(name='apply')
Expand Down Expand Up @@ -133,7 +133,7 @@ def test_task__disable_add_to_parent(self, current_worker_task):
class test_chain(BuiltinsCase):

def setup(self):
BuiltinsCase.setup(self)
super().setup()
self.task = builtins.add_chain_task(self.app)

def test_not_implemented(self):
Expand All @@ -145,7 +145,7 @@ class test_chord(BuiltinsCase):

def setup(self):
self.task = builtins.add_chord_task(self.app)
BuiltinsCase.setup(self)
super().setup()

def test_apply_async(self):
x = chord([self.add.s(i, i) for i in range(10)], body=self.xsum.s())
Expand Down
2 changes: 1 addition & 1 deletion t/unit/app/test_log.py
Expand Up @@ -338,7 +338,7 @@ class MockLogger(logging.Logger):

def __init__(self, *args, **kwargs):
self._records = []
logging.Logger.__init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)

def handle(self, record):
self._records.append(record)
Expand Down
2 changes: 1 addition & 1 deletion t/unit/backends/test_base.py
Expand Up @@ -342,7 +342,7 @@ def delete(self, key):
class DictBackend(BaseBackend):

def __init__(self, *args, **kwargs):
BaseBackend.__init__(self, *args, **kwargs)
super().__init__(*args, **kwargs)
self._data = {'can-delete': {'result': 'foo'}}

def _restore_group(self, group_id):
Expand Down
2 changes: 1 addition & 1 deletion t/unit/utils/test_pickle.py
Expand Up @@ -9,7 +9,7 @@ class ArgOverrideException(Exception):

def __init__(self, message, status_code=10):
self.status_code = status_code
Exception.__init__(self, message, status_code)
super().__init__(message, status_code)


class test_Pickle:
Expand Down
10 changes: 5 additions & 5 deletions t/unit/utils/test_saferepr.py
Expand Up @@ -74,7 +74,7 @@ class list2(list):
class list3(list):

def __repr__(self):
return list.__repr__(self)
return super().__repr__()


class tuple2(tuple):
Expand All @@ -84,7 +84,7 @@ class tuple2(tuple):
class tuple3(tuple):

def __repr__(self):
return tuple.__repr__(self)
return super().__repr__()


class set2(set):
Expand All @@ -94,7 +94,7 @@ class set2(set):
class set3(set):

def __repr__(self):
return set.__repr__(self)
return super().__repr__()


class frozenset2(frozenset):
Expand All @@ -104,7 +104,7 @@ class frozenset2(frozenset):
class frozenset3(frozenset):

def __repr__(self):
return frozenset.__repr__(self)
return super().__repr__()


class dict2(dict):
Expand All @@ -114,7 +114,7 @@ class dict2(dict):
class dict3(dict):

def __repr__(self):
return dict.__repr__(self)
return super().__repr__()


class test_saferepr:
Expand Down
2 changes: 1 addition & 1 deletion t/unit/worker/test_request.py
Expand Up @@ -1142,7 +1142,7 @@ def setup(self):
self.task = Mock(name='task')
self.pool = Mock(name='pool')
self.eventer = Mock(name='eventer')
RequestCase.setup(self)
super().setup()

def create_request_cls(self, **kwargs):
return create_request_cls(
Expand Down

0 comments on commit a061976

Please sign in to comment.