Ver Fonte

No need for dict([list-comprehension]) when we can use dict(generator-expression)

Ask Solem há 16 anos atrás
pai
commit
0eb1627221
3 ficheiros alterados com 6 adições e 6 exclusões
  1. 2 2
      celery/registry.py
  2. 2 2
      celery/result.py
  3. 2 2
      celery/worker/job.py

+ 2 - 2
celery/registry.py

@@ -75,9 +75,9 @@ class TaskRegistry(UserDict):
 
     def filter_types(self, type):
         """Return all tasks of a specific type."""
-        return dict([(task_name, task)
+        return dict((task_name, task)
                         for task_name, task in self.data.items()
-                            if task.type == type])
+                            if task.type == type)
 
     def get_all_regular(self):
         """Get all regular task types."""

+ 2 - 2
celery/result.py

@@ -241,8 +241,8 @@ class TaskSetResult(object):
         :raises: The exception if any of the tasks raised an exception.
 
         """
-        results = dict([(subtask.task_id, AsyncResult(subtask.task_id))
-                            for subtask in self.subtasks])
+        results = dict((subtask.task_id, AsyncResult(subtask.task_id))
+                            for subtask in self.subtasks)
         while results:
             for task_id, pending_result in results.items():
                 if pending_result.status == "DONE":

+ 2 - 2
celery/worker/job.py

@@ -183,8 +183,8 @@ class TaskWrapper(object):
         kwargs = message_data["kwargs"]
 
         # Convert any unicode keys in the keyword arguments to ascii.
-        kwargs = dict([(key.encode("utf-8"), value)
-                    for key, value in kwargs.items()])
+        kwargs = dict((key.encode("utf-8"), value)
+                        for key, value in kwargs.items())
 
         if task_name not in tasks:
             raise NotRegistered(task_name)