瀏覽代碼

PEP8ify + pyflakes

Ask Solem 13 年之前
父節點
當前提交
c8d7979e29

+ 2 - 2
celery/backends/mongodb.py

@@ -181,14 +181,14 @@ class MongoBackend(BaseDictBackend):
     def _forget(self, task_id):
         """
         Remove result from MongoDB.
-        
+
         :raises celery.exceptions.OperationsError: if the task_id could not be
                                                    removed.
         """
 
         db = self._get_database()
         taskmeta_collection = db[self.mongodb_taskmeta_collection]
-        
+
         # By using safe=True, this will wait until it receives a response from
         # the server.  Likewise, it will raise an OperationsError if the
         # response was unable to be completed.

+ 5 - 3
celery/tests/test_backends/test_mongodb.py

@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
 import uuid
 
 from mock import MagicMock, Mock, patch, sentinel
@@ -11,7 +13,7 @@ from celery.tests.utils import unittest
 try:
     import pymongo
 except ImportError:
-    pymongo = None
+    pymongo = None  # noqa
 
 
 COLLECTION = "taskmeta_celery"
@@ -214,7 +216,7 @@ class TestBackendMongoDb(unittest.TestCase):
         mock_get_database.return_value = mock_database
         mock_database.__getitem__.return_value = mock_collection
 
-        ret_val = self.backend._delete_taskset(sentinel.taskset_id)
+        self.backend._delete_taskset(sentinel.taskset_id)
 
         mock_get_database.assert_called_once_with()
         mock_database.__getitem__.assert_called_once_with(MONGODB_COLLECTION)
@@ -248,7 +250,7 @@ class TestBackendMongoDb(unittest.TestCase):
 
         mock_get_database.return_value = mock_database
         mock_database.__getitem__.return_value = mock_collection
-        
+
         self.backend.cleanup()
 
         mock_get_database.assert_called_once_with()

+ 1 - 1
celery/tests/test_concurrency/test_concurrency_eventlet.py

@@ -29,7 +29,7 @@ class test_eventlet_patch(EventletCase):
         prev_eventlet = sys.modules.pop("celery.concurrency.eventlet", None)
         os.environ.pop("EVENTLET_NOPATCH")
         try:
-            import celery.concurrency.eventlet
+            import celery.concurrency.eventlet  # noqa
             self.assertTrue(monkey_patched)
         finally:
             sys.modules["celery.concurrency.eventlet"] = prev_eventlet

+ 1 - 3
celery/tests/test_utils/test_datastructures.py

@@ -264,7 +264,7 @@ class test_DependencyGraph(unittest.TestCase):
             ("A", []),
             ("B", []),
             ("C", ["A"]),
-            ("D", ["C", "B"])
+            ("D", ["C", "B"]),
         ])
 
     def test_repr(self):
@@ -272,7 +272,6 @@ class test_DependencyGraph(unittest.TestCase):
 
     def test_topsort(self):
         order = self.graph1().topsort()
-        print("ORDER: %r" % (order, ))
         # C must start before D
         self.assertLess(order.index("C"), order.index("D"))
         # and B must start before D
@@ -293,4 +292,3 @@ class test_DependencyGraph(unittest.TestCase):
         s = WhateverIO()
         self.graph1().to_dot(s)
         self.assertTrue(s.getvalue())
-

+ 2 - 1
celery/tests/test_worker/__init__.py

@@ -369,7 +369,8 @@ class test_Consumer(unittest.TestCase):
         l.priority_timer.stop()
 
     def test_start_channel_error(self):
-        # Regression test for AMQPChannelExceptions that can occur within the consumer. (i.e. 404 errors)
+        # Regression test for AMQPChannelExceptions that can occur within the
+        # consumer. (i.e. 404 errors)
 
         class MockConsumer(MainConsumer):
             iterations = 0

+ 0 - 4
celery/tests/test_worker/test_bootsteps.py

@@ -124,7 +124,6 @@ class test_StartStopComponent(unittest.TestCase):
         self.assertFalse(x.obj.terminate.call_count)
 
 
-
 class test_Namespace(AppCase):
 
     class NS(abstract.Namespace):
@@ -142,7 +141,6 @@ class test_Namespace(AppCase):
         def import_module(self, module):
             self.imported.append(module)
 
-
     def test_components_added_to_unclaimed(self):
 
         class tnA(abstract.Component):
@@ -227,5 +225,3 @@ class test_Namespace(AppCase):
         x = MyNS(app=self.app)
         x.apply(self)
         self.assertIsNone(x._find_last())
-
-

+ 8 - 10
celery/worker/autoreload.py

@@ -20,6 +20,13 @@ from .. import current_app
 from ..abstract import StartStopComponent
 from ..utils.threads import bgThread, Event
 
+try:
+    import pyinotify
+    _ProcessEvent = pyinotify.ProcessEvent
+except ImportError:
+    pyinotify = None        # noqa
+    _ProcessEvent = object  # noqa
+
 
 class WorkerComponent(StartStopComponent):
     name = "worker.autoreloader"
@@ -90,6 +97,7 @@ class StatMonitor(BaseMonitor):
         except Exception:
             pass
 
+
 class KQueueMonitor(BaseMonitor):
     """File change monitor based on BSD kernel event notifications"""
 
@@ -129,15 +137,6 @@ class KQueueMonitor(BaseMonitor):
                 self._files[f] = None
 
 
-
-try:
-    import pyinotify
-    _ProcessEvent = pyinotify.ProcessEvent
-except ImportError:
-    pyinotify = None        # noqa
-    _ProcessEvent = object  # noqa
-
-
 class InotifyMonitor(_ProcessEvent):
     """File change monitor based on  Linux kernel `inotify` subsystem"""
 
@@ -215,4 +214,3 @@ class Autoreloader(bgThread):
     @staticmethod
     def _module_name(path):
         return os.path.splitext(os.path.basename(path))[0]
-