Skip to content

Commit

Permalink
Run pyupgrade to ensure the code is modernized. (#6808)
Browse files Browse the repository at this point in the history
  • Loading branch information
thedrow committed Jun 13, 2021
1 parent d9d8250 commit ced7493
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion celery/app/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ def __exit__(self, *exc_info):
self.close()

def __repr__(self):
return '<{} {}>'.format(type(self).__name__, appstr(self))
return f'<{type(self).__name__} {appstr(self)}>'

def __reduce__(self):
if self._using_v1_reduce:
Expand Down
2 changes: 1 addition & 1 deletion celery/app/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def get(self, key, default=None):
return getattr(self, key, default)

def __repr__(self):
return '<Context: {!r}>'.format(vars(self))
return f'<Context: {vars(self)!r}>'

def as_execution_options(self):
limit_hard, limit_soft = self.timelimit or (None, None)
Expand Down
2 changes: 1 addition & 1 deletion celery/apps/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def getopt(self, *alt):
raise KeyError(alt[0])

def __repr__(self):
return '<{name}: {0.name}>'.format(self, name=type(self).__name__)
return f'<{type(self).__name__}: {self.name}>'

@cached_property
def pidfile(self):
Expand Down
2 changes: 1 addition & 1 deletion celery/backends/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ def as_uri(self, include_password=False):
"""
# Allow superclass to do work if we don't need to force sanitization
if include_password:
return super(SentinelBackend, self).as_uri(
return super().as_uri(
include_password=include_password,
)
# Otherwise we need to ensure that all components get sanitized rather
Expand Down
2 changes: 1 addition & 1 deletion celery/bin/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

def _set_process_status(prog, info=''):
prog = '{}:{}'.format('celery events', prog)
info = '{} {}'.format(info, strargv(sys.argv))
info = f'{info} {strargv(sys.argv)}'
return set_process_title(prog, info=info)


Expand Down
4 changes: 2 additions & 2 deletions celery/bin/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Thread(Node):
def __init__(self, label, **kwargs):
self.real_label = label
super().__init__(
label='thr-{}'.format(next(tids)),
label=f'thr-{next(tids)}',
pos=0,
)

Expand Down Expand Up @@ -141,7 +141,7 @@ def maybe_abbr(l, name, max=Wmax):
size = len(l)
abbr = max and size > max
if 'enumerate' in args:
l = ['{}{}'.format(name, subscript(i + 1))
l = [f'{name}{subscript(i + 1)}'
for i, obj in enumerate(l)]
if abbr:
l = l[0:max - 1] + [l[size - 1]]
Expand Down
2 changes: 1 addition & 1 deletion celery/utils/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def _iter(self, op):
# changes take precedence.
# pylint: disable=bad-reversed-sequence
# Someone should teach pylint about properties.
return chain(*[op(d) for d in reversed(self.maps)])
return chain(*(op(d) for d in reversed(self.maps)))

def _iterate_keys(self):
# type: () -> Iterable
Expand Down
2 changes: 1 addition & 1 deletion celery/utils/saferepr.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def _chainlist(it, LIT_LIST_SEP=LIT_LIST_SEP):

def _repr_empty_set(s):
# type: (Set) -> str
return '{}()'.format(type(s).__name__)
return f'{type(s).__name__}()'


def _safetext(val):
Expand Down
2 changes: 1 addition & 1 deletion celery/utils/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def pretty(value, width=80, nl_width=80, sep='\n', **kw):
# type: (str, int, int, str, **Any) -> str
"""Format value for printing to console."""
if isinstance(value, dict):
return '{{{0} {1}'.format(sep, pformat(value, 4, nl_width)[1:])
return f'{{{sep} {pformat(value, 4, nl_width)[1:]}'
elif isinstance(value, tuple):
return '{}{}{}'.format(
sep, ' ' * 4, pformat(value, width=nl_width, **kw),
Expand Down
2 changes: 1 addition & 1 deletion celery/utils/timer2.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self, schedule=None, on_error=None, on_tick=None,
self.mutex = threading.Lock()
self.not_empty = threading.Condition(self.mutex)
self.daemon = True
self.name = 'Timer-{}'.format(next(self._timer_count))
self.name = f'Timer-{next(self._timer_count)}'

def _next_entry(self):
with self.not_empty:
Expand Down

0 comments on commit ced7493

Please sign in to comment.