From 06de2f39d2f633164aca7bbbcf10ff152f71aa47 Mon Sep 17 00:00:00 2001 From: Sergey Sayamov Date: Thu, 26 Feb 2026 22:45:07 +0300 Subject: [PATCH] Fixes #868: Fix removing items from list, which is being iterated --- quark/utils/tools.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/quark/utils/tools.py b/quark/utils/tools.py index 0fd1fce0..8822ad04 100644 --- a/quark/utils/tools.py +++ b/quark/utils/tools.py @@ -14,7 +14,7 @@ def remove_dup_list(element): return list(set(element)) -def contains(subset_to_check, target_list): +def contains(subset_to_check: list[str], target_list: list[str]): """ Check the sequence pattern within two list. ----------------------------------------------------------------- @@ -27,12 +27,11 @@ def contains(subset_to_check, target_list): then it will return False. """ - target_copy = copy.copy(target_list) - - # Delete elements that do not exist in the subset_to_check list - for item in target_copy: - if item not in subset_to_check: - target_copy.remove(item) + target_copy = [ + item + for item in target_list + if item in subset_to_check + ] for i in range(len(target_copy) - len(subset_to_check) + 1): for j in range(len(subset_to_check)):