From 69bcbf9b473b0d1dd946df84921e46fdeeff1dfa Mon Sep 17 00:00:00 2001 From: Saeed Rasooli Date: Fri, 6 Sep 2024 00:29:15 +0330 Subject: [PATCH] fix ruff preview error: B909 Mutation to loop iterable during iteration --- pyglossary/core_test.py | 2 +- pyglossary/plugins/appledict_bin/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyglossary/core_test.py b/pyglossary/core_test.py index c02deac96..22a29b027 100644 --- a/pyglossary/core_test.py +++ b/pyglossary/core_test.py @@ -25,7 +25,7 @@ def popLog(self, level: int, msg: str, partial=False) -> "logging.LogRecord | No if level not in self.recordsByLevel: return None records = self.recordsByLevel[level] - for index, record in enumerate(records): + for index, record in list(enumerate(records)): rec_msg = record.getMessage() if msg == rec_msg or (msg in rec_msg and partial): return records.pop(index) diff --git a/pyglossary/plugins/appledict_bin/__init__.py b/pyglossary/plugins/appledict_bin/__init__.py index c55887570..b87ac8488 100644 --- a/pyglossary/plugins/appledict_bin/__init__.py +++ b/pyglossary/plugins/appledict_bin/__init__.py @@ -344,7 +344,7 @@ def _getDefi( ) entryElem.tag = "div" - for attr in entryElem.attrib: + for attr in list(entryElem.attrib.keys()): # if attr == "id" or attr.endswith("title"): del entryElem.attrib[attr]