From fa03ecf96aaea954d89abb42066dc548b26e3469 Mon Sep 17 00:00:00 2001 From: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com> Date: Tue, 27 Oct 2026 18:19:00 +0000 Subject: [PATCH] Fix flake8-bugbear B045 Loop control variable key overrides a variable in an enclosing loop --- cylc/flow/data_store_mgr.py | 9 +++------ cylc/flow/id_cli.py | 19 +++++++++---------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/cylc/flow/data_store_mgr.py b/cylc/flow/data_store_mgr.py index 4f19f38df85..8a3417bc786 100644 --- a/cylc/flow/data_store_mgr.py +++ b/cylc/flow/data_store_mgr.py @@ -789,12 +789,9 @@ def generate_definition_elements(self): # Created family definition elements for first parent # ancestors of graphed tasks. - for key, names in ancestors.items(): - for name in names: - if ( - key == name or - name in families - ): + for names in ancestors.values(): + for name in names[1:]: + if name in families: continue f_id = self.definition_id(name) f_stamp = f'{f_id}@{update_time}' diff --git a/cylc/flow/id_cli.py b/cylc/flow/id_cli.py index d427d40d6e1..b54509c141d 100644 --- a/cylc/flow/id_cli.py +++ b/cylc/flow/id_cli.py @@ -509,16 +509,15 @@ async def _expand_workflow_tokens(tokens_list, match_active=True): if not contains_fnmatch(workflow): # no expansion to perform continue - else: - # remove the original entry - multi_mode = True - tokens_list.remove(tokens) - async for tokens in _expand_workflow_tokens_impl( - tokens, - match_active=match_active, - ): - # add the expanded tokens back onto the list - tokens_list.append(tokens) + # remove the original entry + multi_mode = True + tokens_list.remove(tokens) + async for expanded_tokens in _expand_workflow_tokens_impl( + tokens, + match_active=match_active, + ): + # add the expanded tokens back onto the list + tokens_list.append(expanded_tokens) return multi_mode