taskflow 5.11.0__py3-none-any.whl → 6.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. taskflow/atom.py +3 -5
  2. taskflow/conductors/backends/__init__.py +0 -2
  3. taskflow/conductors/backends/impl_blocking.py +1 -3
  4. taskflow/conductors/backends/impl_executor.py +3 -6
  5. taskflow/conductors/backends/impl_nonblocking.py +1 -3
  6. taskflow/conductors/base.py +1 -3
  7. taskflow/deciders.py +0 -2
  8. taskflow/engines/__init__.py +0 -2
  9. taskflow/engines/action_engine/actions/base.py +1 -3
  10. taskflow/engines/action_engine/actions/retry.py +1 -3
  11. taskflow/engines/action_engine/actions/task.py +1 -3
  12. taskflow/engines/action_engine/builder.py +2 -4
  13. taskflow/engines/action_engine/compiler.py +9 -11
  14. taskflow/engines/action_engine/completer.py +5 -7
  15. taskflow/engines/action_engine/deciders.py +1 -3
  16. taskflow/engines/action_engine/engine.py +4 -26
  17. taskflow/engines/action_engine/executor.py +2 -4
  18. taskflow/engines/action_engine/runtime.py +1 -3
  19. taskflow/engines/action_engine/scheduler.py +3 -5
  20. taskflow/engines/action_engine/scopes.py +3 -5
  21. taskflow/engines/action_engine/selector.py +1 -3
  22. taskflow/engines/action_engine/traversal.py +0 -2
  23. taskflow/engines/base.py +1 -3
  24. taskflow/engines/helpers.py +0 -2
  25. taskflow/engines/worker_based/dispatcher.py +2 -4
  26. taskflow/engines/worker_based/endpoint.py +1 -3
  27. taskflow/engines/worker_based/engine.py +1 -4
  28. taskflow/engines/worker_based/executor.py +0 -2
  29. taskflow/engines/worker_based/protocol.py +1 -3
  30. taskflow/engines/worker_based/proxy.py +2 -4
  31. taskflow/engines/worker_based/server.py +3 -5
  32. taskflow/engines/worker_based/types.py +6 -7
  33. taskflow/engines/worker_based/worker.py +4 -6
  34. taskflow/examples/99_bottles.py +0 -2
  35. taskflow/examples/alphabet_soup.py +0 -2
  36. taskflow/examples/build_a_car.py +1 -3
  37. taskflow/examples/buildsystem.py +1 -3
  38. taskflow/examples/calculate_in_parallel.py +1 -3
  39. taskflow/examples/calculate_linear.py +3 -5
  40. taskflow/examples/create_parallel_volume.py +2 -5
  41. taskflow/examples/delayed_return.py +1 -3
  42. taskflow/examples/distance_calculator.py +12 -24
  43. taskflow/examples/dump_memory_backend.py +1 -3
  44. taskflow/examples/echo_listener.py +0 -2
  45. taskflow/examples/example_utils.py +1 -3
  46. taskflow/examples/fake_billing.py +9 -11
  47. taskflow/examples/graph_flow.py +2 -4
  48. taskflow/examples/hello_world.py +2 -4
  49. taskflow/examples/jobboard_produce_consume_colors.py +3 -5
  50. taskflow/examples/parallel_table_multiply.py +1 -3
  51. taskflow/examples/persistence_example.py +1 -3
  52. taskflow/examples/pseudo_scoping.py +2 -4
  53. taskflow/examples/resume_from_backend.py +1 -3
  54. taskflow/examples/resume_many_flows/my_flows.py +0 -2
  55. taskflow/examples/resume_many_flows/resume_all.py +1 -3
  56. taskflow/examples/resume_many_flows/run_flow.py +2 -4
  57. taskflow/examples/resume_many_flows.py +0 -2
  58. taskflow/examples/resume_vm_boot.py +12 -15
  59. taskflow/examples/resume_volume_create.py +3 -5
  60. taskflow/examples/retry_flow.py +0 -2
  61. taskflow/examples/reverting_linear.py +1 -3
  62. taskflow/examples/run_by_iter.py +0 -2
  63. taskflow/examples/run_by_iter_enumerate.py +1 -3
  64. taskflow/examples/share_engine_thread.py +2 -4
  65. taskflow/examples/simple_linear.py +0 -2
  66. taskflow/examples/simple_linear_listening.py +1 -3
  67. taskflow/examples/simple_linear_pass.py +0 -2
  68. taskflow/examples/simple_map_reduce.py +0 -2
  69. taskflow/examples/switch_graph_flow.py +1 -3
  70. taskflow/examples/timing_listener.py +1 -3
  71. taskflow/examples/tox_conductor.py +3 -5
  72. taskflow/examples/wbe_event_sender.py +0 -2
  73. taskflow/examples/wbe_mandelbrot.py +0 -2
  74. taskflow/examples/wbe_simple_linear.py +0 -2
  75. taskflow/examples/wrapped_exception.py +0 -2
  76. taskflow/exceptions.py +7 -9
  77. taskflow/flow.py +1 -3
  78. taskflow/formatters.py +22 -8
  79. taskflow/jobs/backends/__init__.py +0 -2
  80. taskflow/jobs/backends/impl_redis.py +22 -18
  81. taskflow/jobs/backends/impl_zookeeper.py +7 -8
  82. taskflow/jobs/base.py +5 -7
  83. taskflow/listeners/base.py +1 -3
  84. taskflow/listeners/capturing.py +1 -3
  85. taskflow/listeners/claims.py +1 -3
  86. taskflow/listeners/logging.py +10 -6
  87. taskflow/listeners/printing.py +1 -3
  88. taskflow/listeners/timing.py +10 -13
  89. taskflow/logging.py +0 -2
  90. taskflow/patterns/graph_flow.py +2 -4
  91. taskflow/patterns/linear_flow.py +4 -9
  92. taskflow/patterns/unordered_flow.py +4 -9
  93. taskflow/persistence/backends/__init__.py +1 -3
  94. taskflow/persistence/backends/impl_dir.py +3 -6
  95. taskflow/persistence/backends/impl_memory.py +6 -9
  96. taskflow/persistence/backends/impl_sqlalchemy.py +4 -6
  97. taskflow/persistence/backends/impl_zookeeper.py +2 -4
  98. taskflow/persistence/backends/sqlalchemy/alembic/env.py +0 -2
  99. taskflow/persistence/backends/sqlalchemy/alembic/versions/00af93df9d77_add_unique_into_all_indexes.py +80 -0
  100. taskflow/persistence/backends/sqlalchemy/alembic/versions/14b227d79a87_add_intention_column.py +0 -2
  101. taskflow/persistence/backends/sqlalchemy/alembic/versions/1c783c0c2875_replace_exception_an.py +0 -2
  102. taskflow/persistence/backends/sqlalchemy/alembic/versions/1cea328f0f65_initial_logbook_deta.py +0 -2
  103. taskflow/persistence/backends/sqlalchemy/alembic/versions/2ad4984f2864_switch_postgres_to_json_native.py +0 -2
  104. taskflow/persistence/backends/sqlalchemy/alembic/versions/3162c0f3f8e4_add_revert_results_and_revert_failure_.py +0 -2
  105. taskflow/persistence/backends/sqlalchemy/alembic/versions/589dccdf2b6e_rename_taskdetails_to_atomdetails.py +0 -2
  106. taskflow/persistence/backends/sqlalchemy/alembic/versions/84d6e888850_add_task_detail_type.py +0 -2
  107. taskflow/persistence/backends/sqlalchemy/tables.py +0 -2
  108. taskflow/persistence/base.py +2 -4
  109. taskflow/persistence/models.py +19 -24
  110. taskflow/persistence/path_based.py +1 -3
  111. taskflow/retry.py +12 -18
  112. taskflow/states.py +0 -2
  113. taskflow/storage.py +9 -11
  114. taskflow/task.py +15 -18
  115. taskflow/test.py +5 -5
  116. taskflow/tests/test_examples.py +0 -2
  117. taskflow/tests/unit/action_engine/test_builder.py +1 -3
  118. taskflow/tests/unit/action_engine/test_compile.py +4 -6
  119. taskflow/tests/unit/action_engine/test_creation.py +0 -21
  120. taskflow/tests/unit/action_engine/test_scoping.py +1 -3
  121. taskflow/tests/unit/jobs/base.py +1 -3
  122. taskflow/tests/unit/jobs/test_entrypoint.py +0 -2
  123. taskflow/tests/unit/jobs/test_redis_job.py +1 -3
  124. taskflow/tests/unit/jobs/test_zk_job.py +2 -4
  125. taskflow/tests/unit/patterns/test_graph_flow.py +18 -20
  126. taskflow/tests/unit/patterns/test_linear_flow.py +7 -9
  127. taskflow/tests/unit/patterns/test_unordered_flow.py +12 -14
  128. taskflow/tests/unit/persistence/base.py +2 -4
  129. taskflow/tests/unit/persistence/test_dir_persistence.py +2 -4
  130. taskflow/tests/unit/persistence/test_memory_persistence.py +2 -4
  131. taskflow/tests/unit/persistence/test_sql_persistence.py +4 -6
  132. taskflow/tests/unit/persistence/test_zk_persistence.py +2 -4
  133. taskflow/tests/unit/test_arguments_passing.py +3 -25
  134. taskflow/tests/unit/test_check_transition.py +3 -5
  135. taskflow/tests/unit/test_conductors.py +0 -2
  136. taskflow/tests/unit/test_deciders.py +1 -3
  137. taskflow/tests/unit/test_engine_helpers.py +0 -2
  138. taskflow/tests/unit/test_engines.py +19 -102
  139. taskflow/tests/unit/test_exceptions.py +4 -6
  140. taskflow/tests/unit/test_failure.py +10 -12
  141. taskflow/tests/unit/test_flow_dependencies.py +62 -64
  142. taskflow/tests/unit/test_formatters.py +0 -2
  143. taskflow/tests/unit/test_functor_task.py +1 -3
  144. taskflow/tests/unit/test_listeners.py +9 -11
  145. taskflow/tests/unit/test_mapfunctor_task.py +1 -3
  146. taskflow/tests/unit/test_notifier.py +1 -3
  147. taskflow/tests/unit/test_progress.py +2 -4
  148. taskflow/tests/unit/test_reducefunctor_task.py +1 -3
  149. taskflow/tests/unit/test_retries.py +1 -25
  150. taskflow/tests/unit/test_states.py +0 -2
  151. taskflow/tests/unit/test_storage.py +10 -12
  152. taskflow/tests/unit/test_suspend.py +2 -23
  153. taskflow/tests/unit/test_task.py +17 -19
  154. taskflow/tests/unit/test_types.py +4 -6
  155. taskflow/tests/unit/test_utils.py +9 -11
  156. taskflow/tests/unit/test_utils_async_utils.py +0 -2
  157. taskflow/tests/unit/test_utils_binary.py +12 -14
  158. taskflow/tests/unit/test_utils_iter_utils.py +1 -3
  159. taskflow/tests/unit/test_utils_kazoo_utils.py +0 -2
  160. taskflow/tests/unit/test_utils_threading_utils.py +1 -3
  161. taskflow/tests/unit/worker_based/test_creation.py +0 -2
  162. taskflow/tests/unit/worker_based/test_dispatcher.py +0 -2
  163. taskflow/tests/unit/worker_based/test_endpoint.py +2 -4
  164. taskflow/tests/unit/worker_based/test_executor.py +1 -3
  165. taskflow/tests/unit/worker_based/test_message_pump.py +0 -2
  166. taskflow/tests/unit/worker_based/test_pipeline.py +0 -2
  167. taskflow/tests/unit/worker_based/test_protocol.py +2 -4
  168. taskflow/tests/unit/worker_based/test_proxy.py +2 -4
  169. taskflow/tests/unit/worker_based/test_server.py +3 -5
  170. taskflow/tests/unit/worker_based/test_types.py +0 -2
  171. taskflow/tests/unit/worker_based/test_worker.py +1 -3
  172. taskflow/tests/utils.py +11 -15
  173. taskflow/types/entity.py +1 -3
  174. taskflow/types/failure.py +3 -6
  175. taskflow/types/graph.py +14 -18
  176. taskflow/types/latch.py +1 -3
  177. taskflow/types/notifier.py +6 -9
  178. taskflow/types/sets.py +2 -5
  179. taskflow/types/timing.py +1 -3
  180. taskflow/types/tree.py +6 -10
  181. taskflow/utils/async_utils.py +0 -2
  182. taskflow/utils/banner.py +8 -9
  183. taskflow/utils/eventlet_utils.py +2 -2
  184. taskflow/utils/iter_utils.py +0 -2
  185. taskflow/utils/kazoo_utils.py +7 -9
  186. taskflow/utils/kombu_utils.py +5 -7
  187. taskflow/utils/misc.py +4 -6
  188. taskflow/utils/persistence_utils.py +0 -2
  189. taskflow/utils/redis_utils.py +2 -4
  190. taskflow/utils/schema_utils.py +0 -2
  191. taskflow/utils/threading_utils.py +1 -3
  192. taskflow/version.py +1 -3
  193. {taskflow-5.11.0.dist-info → taskflow-6.0.0.dist-info}/AUTHORS +1 -0
  194. {taskflow-5.11.0.dist-info → taskflow-6.0.0.dist-info}/METADATA +2 -1
  195. taskflow-6.0.0.dist-info/RECORD +243 -0
  196. {taskflow-5.11.0.dist-info → taskflow-6.0.0.dist-info}/WHEEL +1 -1
  197. taskflow-6.0.0.dist-info/pbr.json +1 -0
  198. taskflow/engines/action_engine/process_executor.py +0 -720
  199. taskflow/tests/unit/action_engine/test_process_executor.py +0 -106
  200. taskflow-5.11.0.dist-info/RECORD +0 -244
  201. taskflow-5.11.0.dist-info/pbr.json +0 -1
  202. {taskflow-5.11.0.dist-info → taskflow-6.0.0.dist-info}/LICENSE +0 -0
  203. {taskflow-5.11.0.dist-info → taskflow-6.0.0.dist-info}/entry_points.txt +0 -0
  204. {taskflow-5.11.0.dist-info → taskflow-6.0.0.dist-info}/top_level.txt +0 -0
taskflow/tests/utils.py CHANGED
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2012 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -151,7 +149,7 @@ class GiveBackRevert(task.Task):
151
149
  return result + 1
152
150
 
153
151
 
154
- class FakeTask(object):
152
+ class FakeTask:
155
153
 
156
154
  def execute(self, **kwargs):
157
155
  pass
@@ -169,16 +167,14 @@ RUNTIME_ERROR_CLASSES = ['RuntimeError', 'Exception', 'BaseException',
169
167
 
170
168
  class ProvidesRequiresTask(task.Task):
171
169
  def __init__(self, name, provides, requires, return_tuple=True):
172
- super(ProvidesRequiresTask, self).__init__(name=name,
173
- provides=provides,
174
- requires=requires)
170
+ super().__init__(name=name, provides=provides, requires=requires)
175
171
  self.return_tuple = isinstance(provides, (tuple, list))
176
172
 
177
173
  def execute(self, *args, **kwargs):
178
174
  if self.return_tuple:
179
175
  return tuple(range(len(self.provides)))
180
176
  else:
181
- return dict((k, k) for k in self.provides)
177
+ return {k: k for k in self.provides}
182
178
 
183
179
 
184
180
  # Used to format the captured values into strings (which are easier to
@@ -197,7 +193,7 @@ class CaptureListener(capturing.CaptureListener):
197
193
  name_postfix, name_key = LOOKUP_NAME_POSTFIX[kind]
198
194
  name = details[name_key] + name_postfix
199
195
  if 'result' in details:
200
- name += ' %s(%s)' % (state, details['result'])
196
+ name += ' {}({})'.format(state, details['result'])
201
197
  else:
202
198
  name += " %s" % state
203
199
  return name
@@ -387,9 +383,9 @@ class SleepTask(task.Task):
387
383
  time.sleep(duration)
388
384
 
389
385
 
390
- class EngineTestBase(object):
386
+ class EngineTestBase:
391
387
  def setUp(self):
392
- super(EngineTestBase, self).setUp()
388
+ super().setUp()
393
389
  self.backend = impl_memory.MemoryBackend(conf={})
394
390
 
395
391
  def tearDown(self):
@@ -397,7 +393,7 @@ class EngineTestBase(object):
397
393
  with contextlib.closing(self.backend) as be:
398
394
  with contextlib.closing(be.get_connection()) as conn:
399
395
  conn.clear_all()
400
- super(EngineTestBase, self).tearDown()
396
+ super().tearDown()
401
397
 
402
398
  def _make_engine(self, flow, **kwargs):
403
399
  raise exceptions.NotImplementedError("_make_engine() must be"
@@ -405,7 +401,7 @@ class EngineTestBase(object):
405
401
  " desired")
406
402
 
407
403
 
408
- class FailureMatcher(object):
404
+ class FailureMatcher:
409
405
  """Needed for failure objects comparison."""
410
406
 
411
407
  def __init__(self, failure):
@@ -433,7 +429,7 @@ class OneReturnRetry(retry.AlwaysRevert):
433
429
  class ConditionalTask(ProgressingTask):
434
430
 
435
431
  def execute(self, x, y):
436
- super(ConditionalTask, self).execute()
432
+ super().execute()
437
433
  if x != y:
438
434
  raise RuntimeError('Woot!')
439
435
 
@@ -441,7 +437,7 @@ class ConditionalTask(ProgressingTask):
441
437
  class WaitForOneFromTask(ProgressingTask):
442
438
 
443
439
  def __init__(self, name, wait_for, wait_states, **kwargs):
444
- super(WaitForOneFromTask, self).__init__(name, **kwargs)
440
+ super().__init__(name, **kwargs)
445
441
  if isinstance(wait_for, str):
446
442
  self.wait_for = [wait_for]
447
443
  else:
@@ -458,7 +454,7 @@ class WaitForOneFromTask(ProgressingTask):
458
454
  'for %s to change state to %s'
459
455
  % (WAIT_TIMEOUT, self.wait_for,
460
456
  self.wait_states))
461
- return super(WaitForOneFromTask, self).execute()
457
+ return super().execute()
462
458
 
463
459
  def callback(self, state, details):
464
460
  name = details.get('task_name', None)
taskflow/types/entity.py CHANGED
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2015 Rackspace Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -15,7 +13,7 @@
15
13
  # under the License.
16
14
 
17
15
 
18
- class Entity(object):
16
+ class Entity:
19
17
  """Entity object that identifies some resource/item/other.
20
18
 
21
19
  :ivar kind: **immutable** type/kind that identifies this
taskflow/types/failure.py CHANGED
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2014 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -433,8 +431,8 @@ class Failure():
433
431
  if not self._exc_type_names:
434
432
  buf.write('Failure: %s' % (self._exception_str))
435
433
  else:
436
- buf.write('Failure: %s: %s' % (self._exc_type_names[0],
437
- self._exception_str))
434
+ buf.write('Failure: {}: {}'.format(self._exc_type_names[0],
435
+ self._exception_str))
438
436
  if traceback:
439
437
  if self._traceback_str is not None:
440
438
  traceback_str = self._traceback_str.rstrip()
@@ -452,8 +450,7 @@ class Failure():
452
450
 
453
451
  def __iter__(self):
454
452
  """Iterate over exception type names."""
455
- for et in self._exc_type_names:
456
- yield et
453
+ yield from self._exc_type_names
457
454
 
458
455
  def __getstate__(self):
459
456
  dct = self.to_dict()
taskflow/types/graph.py CHANGED
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2012 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -31,15 +29,15 @@ def _common_format(g, edge_notation):
31
29
  lines.append("Nodes: %s" % g.number_of_nodes())
32
30
  for n, n_data in g.nodes(data=True):
33
31
  if n_data:
34
- lines.append(" - %s (%s)" % (n, n_data))
32
+ lines.append(" - {} ({})".format(n, n_data))
35
33
  else:
36
34
  lines.append(" - %s" % n)
37
35
  lines.append("Edges: %s" % g.number_of_edges())
38
36
  for (u, v, e_data) in g.edges(data=True):
39
37
  if e_data:
40
- lines.append(" %s %s %s (%s)" % (u, edge_notation, v, e_data))
38
+ lines.append(" {} {} {} ({})".format(u, edge_notation, v, e_data))
41
39
  else:
42
- lines.append(" %s %s %s" % (u, edge_notation, v))
40
+ lines.append(" {} {} {}".format(u, edge_notation, v))
43
41
  return lines
44
42
 
45
43
 
@@ -47,8 +45,7 @@ class Graph(nx.Graph):
47
45
  """A graph subclass with useful utility functions."""
48
46
 
49
47
  def __init__(self, incoming_graph_data=None, name=''):
50
- super(Graph, self).__init__(incoming_graph_data=incoming_graph_data,
51
- name=name)
48
+ super().__init__(incoming_graph_data=incoming_graph_data, name=name)
52
49
  self.frozen = False
53
50
 
54
51
  def freeze(self):
@@ -68,14 +65,14 @@ class Graph(nx.Graph):
68
65
  def add_edge(self, u, v, attr_dict=None, **attr):
69
66
  """Add an edge between u and v."""
70
67
  if attr_dict is not None:
71
- return super(Graph, self).add_edge(u, v, **attr_dict)
72
- return super(Graph, self).add_edge(u, v, **attr)
68
+ return super().add_edge(u, v, **attr_dict)
69
+ return super().add_edge(u, v, **attr)
73
70
 
74
71
  def add_node(self, n, attr_dict=None, **attr):
75
72
  """Add a single node n and update node attributes."""
76
73
  if attr_dict is not None:
77
- return super(Graph, self).add_node(n, **attr_dict)
78
- return super(Graph, self).add_node(n, **attr)
74
+ return super().add_node(n, **attr_dict)
75
+ return super().add_node(n, **attr)
79
76
 
80
77
  def fresh_copy(self):
81
78
  """Return a fresh copy graph with the same data structure.
@@ -91,8 +88,7 @@ class DiGraph(nx.DiGraph):
91
88
  """A directed graph subclass with useful utility functions."""
92
89
 
93
90
  def __init__(self, incoming_graph_data=None, name=''):
94
- super(DiGraph, self).__init__(incoming_graph_data=incoming_graph_data,
95
- name=name)
91
+ super().__init__(incoming_graph_data=incoming_graph_data, name=name)
96
92
  self.frozen = False
97
93
 
98
94
  def freeze(self):
@@ -165,7 +161,7 @@ class DiGraph(nx.DiGraph):
165
161
  NOTE(harlowja): predecessor cycles (if they exist) will not be iterated
166
162
  over more than once (this prevents infinite iteration).
167
163
  """
168
- visited = set([n])
164
+ visited = {n}
169
165
  queue = collections.deque(self.predecessors(n))
170
166
  while queue:
171
167
  pred = queue.popleft()
@@ -179,14 +175,14 @@ class DiGraph(nx.DiGraph):
179
175
  def add_edge(self, u, v, attr_dict=None, **attr):
180
176
  """Add an edge between u and v."""
181
177
  if attr_dict is not None:
182
- return super(DiGraph, self).add_edge(u, v, **attr_dict)
183
- return super(DiGraph, self).add_edge(u, v, **attr)
178
+ return super().add_edge(u, v, **attr_dict)
179
+ return super().add_edge(u, v, **attr)
184
180
 
185
181
  def add_node(self, n, attr_dict=None, **attr):
186
182
  """Add a single node n and update node attributes."""
187
183
  if attr_dict is not None:
188
- return super(DiGraph, self).add_node(n, **attr_dict)
189
- return super(DiGraph, self).add_node(n, **attr)
184
+ return super().add_node(n, **attr_dict)
185
+ return super().add_node(n, **attr)
190
186
 
191
187
  def fresh_copy(self):
192
188
  """Return a fresh copy graph with the same data structure.
taskflow/types/latch.py CHANGED
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2014 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -19,7 +17,7 @@ import threading
19
17
  from oslo_utils import timeutils
20
18
 
21
19
 
22
- class Latch(object):
20
+ class Latch:
23
21
  """A class that ensures N-arrivals occur before unblocking.
24
22
 
25
23
  TODO(harlowja): replace with http://bugs.python.org/issue8777 when we no
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2014 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -24,7 +22,7 @@ from oslo_utils import reflection
24
22
  LOG = logging.getLogger(__name__)
25
23
 
26
24
 
27
- class Listener(object):
25
+ class Listener:
28
26
  """Immutable helper that represents a notification listener/target."""
29
27
 
30
28
  def __init__(self, callback, args=None, kwargs=None, details_filter=None):
@@ -89,7 +87,7 @@ class Listener(object):
89
87
  self._callback(event_type, *self._args, **kwargs)
90
88
 
91
89
  def __repr__(self):
92
- repr_msg = "%s object at 0x%x calling into '%r'" % (
90
+ repr_msg = "{} object at 0x{:x} calling into '{!r}'".format(
93
91
  reflection.get_class_name(self, fully_qualified=False),
94
92
  id(self), self._callback)
95
93
  if self._details_filter is not None:
@@ -126,7 +124,7 @@ class Listener(object):
126
124
  return not self.__eq__(other)
127
125
 
128
126
 
129
- class Notifier(object):
127
+ class Notifier:
130
128
  """A notification (`pub/sub`_ *like*) helper class.
131
129
 
132
130
  It is intended to be used to subscribe to notifications of events
@@ -151,7 +149,7 @@ class Notifier(object):
151
149
  ANY = '*'
152
150
 
153
151
  #: Events which can *not* be used to trigger notifications
154
- _DISALLOWED_NOTIFICATION_EVENTS = set([ANY])
152
+ _DISALLOWED_NOTIFICATION_EVENTS = {ANY}
155
153
 
156
154
  def __init__(self):
157
155
  self._topics = collections.defaultdict(list)
@@ -321,7 +319,7 @@ class RestrictedNotifier(Notifier):
321
319
  """
322
320
 
323
321
  def __init__(self, watchable_events, allow_any=True):
324
- super(RestrictedNotifier, self).__init__()
322
+ super().__init__()
325
323
  self._watchable_events = frozenset(watchable_events)
326
324
  self._allow_any = allow_any
327
325
 
@@ -332,8 +330,7 @@ class RestrictedNotifier(Notifier):
332
330
  meta-type is not a specific event but is a capture-all that does not
333
331
  imply the same meaning as specific event types.
334
332
  """
335
- for event_type in self._watchable_events:
336
- yield event_type
333
+ yield from self._watchable_events
337
334
 
338
335
  def can_be_registered(self, event_type):
339
336
  """Checks if the event can be registered/subscribed to.
taskflow/types/sets.py CHANGED
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2015 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -57,8 +55,7 @@ class OrderedSet(abc.Set, abc.Hashable):
57
55
  return len(self._data)
58
56
 
59
57
  def __iter__(self):
60
- for value in self._data.keys():
61
- yield value
58
+ yield from self._data.keys()
62
59
 
63
60
  def __setstate__(self, items):
64
61
  self.__init__(iterable=iter(items))
@@ -67,7 +64,7 @@ class OrderedSet(abc.Set, abc.Hashable):
67
64
  return tuple(self)
68
65
 
69
66
  def __repr__(self):
70
- return "%s(%s)" % (type(self).__name__, list(self))
67
+ return "{}({})".format(type(self).__name__, list(self))
71
68
 
72
69
  def copy(self):
73
70
  """Return a shallow copy of a set."""
taskflow/types/timing.py CHANGED
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2014 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -17,7 +15,7 @@
17
15
  import threading
18
16
 
19
17
 
20
- class Timeout(object):
18
+ class Timeout:
21
19
  """An object which represents a timeout.
22
20
 
23
21
  This object has the ability to be interrupted before the actual timeout
taskflow/types/tree.py CHANGED
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2014 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -28,10 +26,10 @@ class FrozenNode(Exception):
28
26
  """Exception raised when a frozen node is modified."""
29
27
 
30
28
  def __init__(self):
31
- super(FrozenNode, self).__init__("Frozen node(s) can't be modified")
29
+ super().__init__("Frozen node(s) can't be modified")
32
30
 
33
31
 
34
- class _DFSIter(object):
32
+ class _DFSIter:
35
33
  """Depth first iterator (non-recursive) over the child nodes."""
36
34
 
37
35
  def __init__(self, root, include_self=False, right_to_left=True):
@@ -60,7 +58,7 @@ class _DFSIter(object):
60
58
  stack.extend(iter(node))
61
59
 
62
60
 
63
- class _BFSIter(object):
61
+ class _BFSIter:
64
62
  """Breadth first iterator (non-recursive) over the child nodes."""
65
63
 
66
64
  def __init__(self, root, include_self=False, right_to_left=False):
@@ -89,7 +87,7 @@ class _BFSIter(object):
89
87
  q.extend(node.reverse_iter())
90
88
 
91
89
 
92
- class Node(object):
90
+ class Node:
93
91
  """A n-ary node class that can be used to create tree structures."""
94
92
 
95
93
  #: Default string prefix used in :py:meth:`.pformat`.
@@ -358,13 +356,11 @@ class Node(object):
358
356
 
359
357
  def __iter__(self):
360
358
  """Iterates over the direct children of this node (right->left)."""
361
- for c in self._children:
362
- yield c
359
+ yield from self._children
363
360
 
364
361
  def reverse_iter(self):
365
362
  """Iterates over the direct children of this node (left->right)."""
366
- for c in reversed(self._children):
367
- yield c
363
+ yield from reversed(self._children)
368
364
 
369
365
  def index(self, item):
370
366
  """Finds the child index of a given item, searches in added order."""
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2013 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
taskflow/utils/banner.py CHANGED
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2016 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -74,12 +72,13 @@ def make_banner(what, chapters):
74
72
  section_names = sorted(chapter_contents.keys())
75
73
  for j, section_name in enumerate(section_names):
76
74
  if j + 1 < len(section_names):
77
- buf.write_nl(" %s => %s"
78
- % (section_name,
79
- chapter_contents[section_name]))
75
+ buf.write_nl(" {} => {}".format(
76
+ section_name,
77
+ chapter_contents[section_name]))
80
78
  else:
81
- buf.write(" %s => %s" % (section_name,
82
- chapter_contents[section_name]))
79
+ buf.write(" {} => {}".format(
80
+ section_name,
81
+ chapter_contents[section_name]))
83
82
  elif isinstance(chapter_contents, (list, tuple, set)):
84
83
  if isinstance(chapter_contents, set):
85
84
  sections = sorted(chapter_contents)
@@ -87,9 +86,9 @@ def make_banner(what, chapters):
87
86
  sections = chapter_contents
88
87
  for j, section in enumerate(sections):
89
88
  if j + 1 < len(sections):
90
- buf.write_nl(" %s. %s" % (j + 1, section))
89
+ buf.write_nl(" {}. {}".format(j + 1, section))
91
90
  else:
92
- buf.write(" %s. %s" % (j + 1, section))
91
+ buf.write(" {}. {}".format(j + 1, section))
93
92
  else:
94
93
  raise TypeError("Unsupported chapter contents"
95
94
  " type: one of dict, list, tuple, set expected"
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2015 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -14,6 +12,7 @@
14
12
  # License for the specific language governing permissions and limitations
15
13
  # under the License.
16
14
 
15
+ import debtcollector.removals
17
16
  from oslo_utils import importutils
18
17
 
19
18
  _eventlet = importutils.try_import('eventlet')
@@ -21,6 +20,7 @@ _eventlet = importutils.try_import('eventlet')
21
20
  EVENTLET_AVAILABLE = bool(_eventlet)
22
21
 
23
22
 
23
+ @debtcollector.removals.remove(message='Eventlet support is deprecated.')
24
24
  def check_for_eventlet(exc=None):
25
25
  """Check if eventlet is available and if not raise a runtime error.
26
26
 
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2015 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2014 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -41,7 +39,7 @@ def _parse_hosts(hosts):
41
39
  if isinstance(hosts, (dict)):
42
40
  host_ports = []
43
41
  for (k, v) in hosts.items():
44
- host_ports.append("%s:%s" % (k, v))
42
+ host_ports.append("{}:{}".format(k, v))
45
43
  hosts = host_ports
46
44
  if isinstance(hosts, (list, set, tuple)):
47
45
  return ",".join([str(h) for h in hosts])
@@ -65,7 +63,7 @@ def prettify_failures(failures, limit=-1):
65
63
  pass
66
64
  pretty_op += "(%s)" % (", ".join(selected_attrs))
67
65
  pretty_cause = reflection.get_class_name(r, fully_qualified=False)
68
- prettier.append("%s@%s" % (pretty_cause, pretty_op))
66
+ prettier.append("{}@{}".format(pretty_cause, pretty_op))
69
67
  if limit <= 0 or len(prettier) <= limit:
70
68
  return ", ".join(prettier)
71
69
  else:
@@ -78,7 +76,7 @@ class KazooTransactionException(k_exc.KazooException):
78
76
  """Exception raised when a checked commit fails."""
79
77
 
80
78
  def __init__(self, message, failures):
81
- super(KazooTransactionException, self).__init__(message)
79
+ super().__init__(message)
82
80
  self._failures = tuple(failures)
83
81
 
84
82
  @property
@@ -134,8 +132,8 @@ def check_compatible(client, min_version=None, max_version=None):
134
132
  """
135
133
  server_version = None
136
134
  if min_version:
137
- server_version = tuple((int(a) for a in client.server_version()))
138
- min_version = tuple((int(a) for a in min_version))
135
+ server_version = tuple(int(a) for a in client.server_version())
136
+ min_version = tuple(int(a) for a in min_version)
139
137
  if server_version < min_version:
140
138
  pretty_server_version = ".".join([str(a) for a in server_version])
141
139
  min_version = ".".join([str(a) for a in min_version])
@@ -145,8 +143,8 @@ def check_compatible(client, min_version=None, max_version=None):
145
143
  min_version))
146
144
  if max_version:
147
145
  if server_version is None:
148
- server_version = tuple((int(a) for a in client.server_version()))
149
- max_version = tuple((int(a) for a in max_version))
146
+ server_version = tuple(int(a) for a in client.server_version())
147
+ max_version = tuple(int(a) for a in max_version)
150
148
  if server_version > max_version:
151
149
  pretty_server_version = ".".join([str(a) for a in server_version])
152
150
  max_version = ".".join([str(a) for a in max_version])
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2015 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -22,7 +20,7 @@ _MSG_PROPERTIES = tuple([
22
20
  ])
23
21
 
24
22
 
25
- class DelayedPretty(object):
23
+ class DelayedPretty:
26
24
  """Wraps a message and delays prettifying it until requested.
27
25
 
28
26
  TODO(harlowja): remove this when https://github.com/celery/kombu/pull/454/
@@ -70,7 +68,7 @@ def _prettify_message(message):
70
68
  properties[segments[-1]] = value
71
69
  if message.body is not None:
72
70
  properties['body_length'] = len(message.body)
73
- return "%(delivery_tag)s: %(properties)s" % {
74
- 'delivery_tag': message.delivery_tag,
75
- 'properties': properties,
76
- }
71
+ return "{delivery_tag}: {properties}".format(
72
+ delivery_tag=message.delivery_tag,
73
+ properties=properties,
74
+ )
taskflow/utils/misc.py CHANGED
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2012 Yahoo! Inc. All Rights Reserved.
4
2
  # Copyright (C) 2013 Rackspace Hosting All Rights Reserved.
5
3
  #
@@ -55,7 +53,7 @@ class StrEnum(str, enum.Enum):
55
53
  if not isinstance(a, str):
56
54
  raise TypeError("Enumeration '%s' (%s) is not"
57
55
  " a string" % (a, type(a).__name__))
58
- return super(StrEnum, cls).__new__(cls, *args, **kwargs)
56
+ return super().__new__(cls, *args, **kwargs)
59
57
 
60
58
 
61
59
  class StringIO(io.StringIO):
@@ -82,7 +80,7 @@ def get_hostname(unknown_hostname=UNKNOWN_HOSTNAME):
82
80
  return unknown_hostname
83
81
  else:
84
82
  return hostname
85
- except socket.error:
83
+ except OSError:
86
84
  return unknown_hostname
87
85
 
88
86
 
@@ -189,7 +187,7 @@ def find_subclasses(locations, base_cls, exclude_hidden=True):
189
187
  except ValueError:
190
188
  module = importutils.import_module(item)
191
189
  else:
192
- obj = importutils.import_class('%s.%s' % (pkg, cls))
190
+ obj = importutils.import_class('{}.{}'.format(pkg, cls))
193
191
  if not reflection.is_subclass(obj, base_cls):
194
192
  raise TypeError("Object '%s' (%s) is not a '%s' subclass"
195
193
  % (item, type(item), base_cls))
@@ -343,7 +341,7 @@ def decode_json(raw_data, root_types=(dict,)):
343
341
  return _check_decoded_type(data, root_types=root_types)
344
342
 
345
343
 
346
- class cachedproperty(object):
344
+ class cachedproperty:
347
345
  """A *thread-safe* descriptor property that is only evaluated once.
348
346
 
349
347
  This caching descriptor can be placed on instance methods to translate
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2012 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2015 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -41,7 +39,7 @@ class RedisClient(redis.Redis):
41
39
  """
42
40
 
43
41
  def __init__(self, *args, **kwargs):
44
- super(RedisClient, self).__init__(*args, **kwargs)
42
+ super().__init__(*args, **kwargs)
45
43
  self.closed = False
46
44
 
47
45
  def close(self):
@@ -71,7 +69,7 @@ class UnknownExpire(enum.IntEnum):
71
69
  DOES_NOT_EXPIRE = UnknownExpire.DOES_NOT_EXPIRE
72
70
  KEY_NOT_FOUND = UnknownExpire.KEY_NOT_FOUND
73
71
 
74
- _UNKNOWN_EXPIRE_MAPPING = dict((e.value, e) for e in list(UnknownExpire))
72
+ _UNKNOWN_EXPIRE_MAPPING = {e.value: e for e in list(UnknownExpire)}
75
73
 
76
74
 
77
75
  def get_expiry(client, key, prior_version=None):
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2015 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2013 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -73,7 +71,7 @@ def no_op(*args, **kwargs):
73
71
  """Function that does nothing."""
74
72
 
75
73
 
76
- class ThreadBundle(object):
74
+ class ThreadBundle:
77
75
  """A group/bundle of threads that start/stop together."""
78
76
 
79
77
  def __init__(self):
taskflow/version.py CHANGED
@@ -1,5 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  # Copyright (C) 2013 Yahoo! Inc. All Rights Reserved.
4
2
  #
5
3
  # Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -28,4 +26,4 @@ def version_string_with_package():
28
26
  if TASK_PACKAGE is None:
29
27
  return version_string()
30
28
  else:
31
- return "%s-%s" % (version_string(), TASK_PACKAGE)
29
+ return "{}-{}".format(version_string(), TASK_PACKAGE)