8000 Flakes · alex-python/celery@8997c26 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8997c26

Browse files
committed
Flakes
1 parent 96934ae commit 8997c26

File tree

15 files changed

+48
-37
lines changed

15 files changed

+48
-37
lines changed

celery/app/base.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
from __future__ import absolute_import
1010

1111
import os
12-
import sys
1312
import threading
1413
import warnings
1514

1615
from collections import defaultdict, deque
17-
from contextlib import contextmanager
1816
from copy import deepcopy
1917
from operator import attrgetter
2018

celery/app/log.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ def setup_task_loggers(self, loglevel=None, logfile=None, format=None,
176176
formatter=TaskFormatter, **kwargs
177177
)
178178
logger.setLevel(loglevel)
179-
logger.propagate = int(propagate) # this is an int for some reason.
180-
# better to not question why.
179+
# this is an int for some reason, better not question why.
180+
logger.propagate = int(propagate)
181181
signals.after_setup_task_logger.send(
182182
sender=None, logger=logger,
183183
loglevel=loglevel, logfile=logfile,

celery/concurrency/asynpool.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ def _create_write_handlers(self, hub,
603603
active_writers = self._active_writers
604604
busy_workers = self._busy_workers
605605
diff = all_inqueues.difference
606-
add_reader, add_writer = hub.add_reader, hub.add_writer
606+
add_writer = hub.add_writer
607607
hub_add, hub_remove = hub.add, hub.remove
608608
mark_write_fd_as_active = active_writes.add
609609
mark_write_gen_as_active = active_writers.add
@@ -646,8 +646,6 @@ def _put_back(job, _time=time.time):
646646

647647
def on_poll_start():
648648
if outbound and len(busy_workers) < len(all_inqueues):
649-
#print('ALL: %r ACTIVE: %r' % (len(all_inqueues),
650-
# len(active_writes)))
651649
inactive = diff(active_writes)
652650
[hub_add(fd, None, WRITE | ERR, consolidate=True)
653651
for fd in inactive]
@@ -1155,8 +1153,6 @@ def on_partial_read(self, job, proc):
11551153
self._queues[self.create_process_queues()] = None
11561154
except ValueError:
11571155
pass
1158-
# Not in queue map, make sure sockets are closed.
1159-
#self.destroy_queues((proc.inq, proc.outq, proc.synq))
11601156
assert len(self._queues) == before
11611157

11621158
def destroy_queues(self, queues, proc):

celery/five.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
def Counter(): # noqa
2929
return defaultdict(int)
3030

31-
############## py3k #########################################################
31+
# ############# py3k #########################################################
3232
import sys
3333
PY3 = sys.version_info[0] == 3
3434

@@ -144,17 +144,17 @@ def _clone_with_metaclass(Class):
144144
return _clone_with_metaclass
145145

146146

147-
############## collections.OrderedDict ######################################
147+
# ############# collections.OrderedDict ######################################
148148
# was moved to kombu
149149
from kombu.utils.compat import OrderedDict # noqa
150150

151-
############## threading.TIMEOUT_MAX #######################################
151+
# ############# threading.TIMEOUT_MAX ########################################
152152
try:
153153
from threading import TIMEOUT_MAX as THREAD_TIMEOUT_MAX
154154
except ImportError:
155155
THREAD_TIMEOUT_MAX = 1e10 # noqa
156156

157-
############## format(int, ',d') ##########################
157+
# ############# format(int, ',d') ############################################
158158

159159
if sys.version_info >= (2, 7): # pragma: no cover
160160
def format_d(i):
@@ -169,7 +169,7 @@ def format_d(i): # noqa
169169
return s + ','.join(reversed(groups))
170170

171171

172-
############## Module Generation ##########################
172+
# ############# Module Generation ############################################
173173

174174
# Utilities to dynamically
175175
# recreate modules, either for lazy loading or

celery/loaders/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,12 @@ def getarg(arg):
190190
"""Parse a single configuration definition from
191191
the command-line."""
192192

193-
## find key/value
193+
# ## find key/value
194194
# ns.key=value|ns_key=value (case insensitive)
195195
key, value = arg.split('=', 1)
196196
key = key.upper().replace('.', '_')
197197

198-
## find namespace.
198+
# ## find namespace.
199199
# .key=value|_key=value expands to default namespace.
200200
if key[0] == '_':
201201
ns, key = namespace, key[1:]

celery/task/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Task(BaseTask):
3838
__bound__ = False
3939
__v2_compat__ = True
4040

41-
#- Deprecated compat. attributes -:
41+
# - Deprecated compat. attributes -:
4242

4343
queue = None
4444
routing_key = None

celery/tests/backends/test_amqp.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,16 @@ def test_get_many(self):
271271
tids.append(tid)
272272

273273
res = list(b.get_many(tids, timeout=1))
274-
expected_results = [(tid, {'status': states.SUCCESS,
275-
'result': i,
276-
'traceback': None,
277-
'task_id': tid,
278-
'children': None})
279-
for i, tid in enumerate(tids)]
274+
expected_results = [
275+
(task_id, {
276+
'status': states.SUCCESS,
277+
'result': i,
278+
'traceback': None,
279+
'task_id': tid,
280+
'children': None,
281+
})
282+
for i, task_id in enumerate(tids)
283+
]
280284
self.assertEqual(sorted(res), sorted(expected_results))
281285
self.assertDictEqual(b._cache[res[0][0]], res[0][1])
282286
cached_res = list(b.get_many(tids, timeout=1))

celery/tests/bin/test_worker.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,10 @@ def test_startup_info(self):
206206
# test when there are too few output lines
207207
# to draft the ascii art onto
208208
prev, cd.ARTLINES = cd.ARTLINES, ['the quick brown fox']
209 10662 -
self.assertTrue(worker.startup_info())
209+
try:
210+
self.assertTrue(worker.startup_info())
211+
finally:
212+
cd.ARTLINES = prev
210213

211214
@disable_stdouts
212215
def test_run(self):
@@ -322,8 +325,11 @@ def test_setup_logging_no_color(self):
322325
app=self.app, redirect_stdouts=False, no_color=True,
323326
)
324327
prev, self.app.log.setup = self.app.log.setup, Mock()
325-
worker.setup_logging()
326-
self.assertFalse(self.app.log.setup.call_args[1]['colorize'])
328+
try:
329+
worker.setup_logging()
330+
self.assertFalse(self.app.log.setup.call_args[1]['colorize'])
331+
finally:
332+
self.app.log.setup = prev
327333

328334
@disable_stdouts
329335
def test_startup_info_pool_is_str(self):

celery/tests/case.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def _is_magic_module(m):
235235

236236
# pyflakes refuses to accept 'noqa' for this isinstance.
237237
cls, modtype = m.__class__, types.ModuleType
238-
return (not cls is modtype and (
238+
return (cls is not modtype and (
239239
'__getattr__' in vars(m.__class__) or
240240
'__getattribute__' in vars(m.__class__)))
241241

celery/tests/compat_modules/test_sets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ def test_is_JSON_serializable(self):
134134
s = self.MockTask.subtask(
135135
(2, ), {'cache': True}, {'routing_key': 'CPU-bound'},
136136
)
137-
s.args = list(s.args) # tuples are not preserved
138-
# but this doesn't matter.
137+
# tuples are not preserved, but this doesn't matter.
138+
s.args = list(s.args)
139139
self.assertEqual(s, self.subtask(anyjson.loads(anyjson.dumps(s))))
140140

141141
def test_repr(self):

0 commit comments

Comments
 (0)
0