diff --git a/mistral/engine/dispatcher.py b/mistral/engine/dispatcher.py index 32ad72c77..95196b0a5 100644 --- a/mistral/engine/dispatcher.py +++ b/mistral/engine/dispatcher.py @@ -49,7 +49,7 @@ def _rearrange_commands(cmds): """ # Remove all 'noop' commands. - cmds = list(filter(lambda c: not isinstance(c, commands.Noop), cmds)) + cmds = list([c for c in cmds if not isinstance(c, commands.Noop)]) state_cmd_idx = -1 state_cmd = None diff --git a/mistral/engine/tasks.py b/mistral/engine/tasks.py index 52a8a8617..dee0eec77 100644 --- a/mistral/engine/tasks.py +++ b/mistral/engine/tasks.py @@ -327,13 +327,9 @@ class RegularTask(Task): if self.reset_flag: execs = self.task_ex.executions else: - execs = filter( - lambda e: ( - e.accepted and - e.state in [states.ERROR, states.CANCELLED] - ), - self.task_ex.executions - ) + execs = [e for e in self.task_ex.executions if + (e.accepted and + e.state in [states.ERROR, states.CANCELLED])] for ex in execs: ex.accepted = False @@ -598,7 +594,7 @@ class WithItemsTask(RegularTask): if list(filter(find_cancelled, self.task_ex.executions)): return True - execs = list(filter(lambda t: t.accepted, self.task_ex.executions)) + execs = list([t for t in self.task_ex.executions if t.accepted]) count = self._get_with_items_count() or 1 # We need to make sure that method on_action_complete() has been @@ -629,10 +625,8 @@ class WithItemsTask(RegularTask): def _get_accepted_executions(self): # Choose only if not accepted but completed. return list( - filter( - lambda x: x.accepted and states.is_completed(x.state), - self.task_ex.executions - ) + [x for x in self.task_ex.executions + if x.accepted and states.is_completed(x.state)] ) def _get_unaccepted_executions(self): diff --git a/mistral/engine/workflows.py b/mistral/engine/workflows.py index a041aa7b5..4fcfbcd3c 100644 --- a/mistral/engine/workflows.py +++ b/mistral/engine/workflows.py @@ -165,7 +165,7 @@ class Workflow(object): # commands because workflow controller takes tasks that # completed within the period when the workflow was paused. cmds = list( - filter(lambda c: not isinstance(c, commands.PauseWorkflow), cmds) + [c for c in cmds if not isinstance(c, commands.PauseWorkflow)] ) # Since there's no explicit task causing the operation diff --git a/mistral/tests/unit/base.py b/mistral/tests/unit/base.py index c2a6f8d1b..eef902b22 100644 --- a/mistral/tests/unit/base.py +++ b/mistral/tests/unit/base.py @@ -136,7 +136,7 @@ class BaseTest(base.BaseTestCase): return True filtered_items = list( - filter(lambda item: _matches(item, **props), items) + [item for item in items if _matches(item, **props)] ) found = len(filtered_items) diff --git a/mistral/workbook/v2/workflows.py b/mistral/workbook/v2/workflows.py index 604e72550..e2337b352 100644 --- a/mistral/workbook/v2/workflows.py +++ b/mistral/workbook/v2/workflows.py @@ -335,7 +335,7 @@ class DirectWorkflowSpec(WorkflowSpec): @staticmethod def _remove_task_from_clause(on_clause, t_name): - return list(filter(lambda tup: tup[0] != t_name, on_clause)) + return list([tup for tup in on_clause if tup[0] != t_name]) class ReverseWorkflowSpec(WorkflowSpec): diff --git a/mistral_tempest_tests/services/base.py b/mistral_tempest_tests/services/base.py index 02c534ab9..a69817e5a 100644 --- a/mistral_tempest_tests/services/base.py +++ b/mistral_tempest_tests/services/base.py @@ -41,7 +41,7 @@ def find_items(items, **props): return True - filtered = list(filter(lambda item: _matches(item, **props), items)) + filtered = list([item for item in items if _matches(item, **props)]) if len(filtered) == 1: return filtered[0] diff --git a/mistral_tempest_tests/tests/scenario/engine/actions/v2/test_ssh_actions.py b/mistral_tempest_tests/tests/scenario/engine/actions/v2/test_ssh_actions.py index e267842cb..baebae58c 100644 --- a/mistral_tempest_tests/tests/scenario/engine/actions/v2/test_ssh_actions.py +++ b/mistral_tempest_tests/tests/scenario/engine/actions/v2/test_ssh_actions.py @@ -79,7 +79,7 @@ class SSHActionsTestsV2(base.TestCaseAdvanced): 'floating_ips' ) free_ips = list( - filter(lambda fl_ip: fl_ip['instance_id'] is None, all_ips) + [fl_ip for fl_ip in all_ips if fl_ip['instance_id'] is None] ) if free_ips: