Disable the loop-iterator-mutation rule in ruff#3450
Disable the loop-iterator-mutation rule in ruff#3450svartkanin merged 1 commit intoarchlinux:masterfrom
Conversation
This allows ruff check --preview to succeed again.
|
Why not fix it rather than suppress it? Would this be preferable? diff --git a/archinstall/lib/pacman/config.py b/archinstall/lib/pacman/config.py
index 6ea75d4e..948db2de 100644
--- a/archinstall/lib/pacman/config.py
+++ b/archinstall/lib/pacman/config.py
@@ -33,7 +33,10 @@ class PacmanConfig:
content = self._config_path.read_text().splitlines(keepends=True)
- for row, line in enumerate(content):
+ row = 0
+ while row < len(content):
+ line = content[row]
+
# Check if this is a commented repository section that needs to be enabled
match = re.match(r'^#\s*\[(.*)\]', line)
@@ -44,6 +47,9 @@ class PacmanConfig:
# also uncomment the next line (Include statement) if it exists and is commented
if row + 1 < len(content) and content[row + 1].lstrip().startswith('#'):
content[row + 1] = re.sub(r'^#\s*', '', content[row + 1])
+ row += 1
+
+ row += 1
# Write the modified content back to the file
with open(self._config_path, 'w') as f:This also enables skipping |
I opted to disable the rule for now because a similar In the long run, I would like most of the current exclusions to be re-enabled because I think they can eventually help catch more issues. In the short term, I am mainly trying to keep The proposed patch looks good, but some people may find it a bit harder to read because of the double increment. Manual increments can also lead to infinite loops if |
PR Description:
This allows
ruff check --previewto succeed again.Here's the warning that is now suppressed: