Skip to content

Commit c5ac95a

Browse files
committed
Avoid B007 hound warning
We use the line number only outside the loop which triggers > Loop control variable 'num' not used within the loop body. If this is intended, start the name with an underscore.
1 parent fb11ab3 commit c5ac95a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

easybuild/easyblocks/generic/cargo.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,17 @@ def parse_toml(file_or_content: Union[Path, str]) -> Dict[str, str]:
164164
expected_end = None
165165
current_section = None
166166
content = read_file(file_or_content) if isinstance(file_or_content, Path) else file_or_content
167-
num = raw_line = None
167+
line_num = 0
168+
raw_line = None
168169
start_end = {
169170
'[': ']',
170171
'{': '}',
171172
'"""': '"""',
172173
"'''": "'''",
173174
}
174175
try:
175-
for num, raw_line in enumerate(content.splitlines()):
176+
for raw_line in content.splitlines():
177+
line_num += 1
176178
line: str = _clean_line(raw_line, expected_end)
177179
if not line:
178180
continue
@@ -196,7 +198,7 @@ def parse_toml(file_or_content: Union[Path, str]) -> Dict[str, str]:
196198
result[current_section][pending_key] = pending_value.strip()
197199
pending_key = None
198200
except Exception as e:
199-
raise ValueError(f'Failed to parse {file_or_content}, error {e} at line {num}: {raw_line}')
201+
raise ValueError(f'Failed to parse {file_or_content}, error {e} at line {line_num}: {raw_line}')
200202
return result
201203

202204

0 commit comments

Comments
 (0)