fix: Resolve 21 ruff linting errors (SIM102, SIM117, B904, SIM113, B007)

Fixed all 21 linting errors identified in GitHub Actions:

SIM102 (7 errors - nested if statements):
- config_extractor.py:468 - Combined nested conditions
- config_validator.py (was B904, already fixed)
- pattern_recognizer.py:430,538,916 - Combined nested conditions
- test_example_extractor.py:365,412,460 - Combined nested conditions
- unified_skill_builder.py:1070 - Combined nested conditions

SIM117 (9 errors - multiple with statements):
- test_install_agent.py:418 - Combined with statements
- test_issue_219_e2e.py:278 - Combined with statements
- test_llms_txt_downloader.py:33,88 - Combined with statements
- test_skip_llms_txt.py:75,98,121,148,172,304 - Combined with statements

B904 (1 error - exception handling):
- config_validator.py:62 - Added 'from e' to exception chain

SIM113 (1 error - enumerate usage):
- doc_scraper.py:1068 - Removed unused 'completed' counter variable

B007 (1 error - unused loop variable):
- pdf_scraper.py:167 - Changed 'keywords' to '_' for unused variable

All changes improve code quality without altering functionality.
Tests: 1214 passed, 167 skipped (4 pre-existing failures unrelated)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
yusyus
2026-01-17 23:54:22 +03:00
parent 6439c85cde
commit 9666938eb0
11 changed files with 173 additions and 199 deletions

View File

@@ -466,24 +466,23 @@ class ConfigParser:
tree = ast.parse(config_file.raw_content)
for node in ast.walk(tree):
if isinstance(node, ast.Assign):
# Get variable name and skip private variables
if len(node.targets) == 1 and isinstance(node.targets[0], ast.Name) and not node.targets[0].id.startswith("_"):
key = node.targets[0].id
# Get variable name and skip private variables
if isinstance(node, ast.Assign) and len(node.targets) == 1 and isinstance(node.targets[0], ast.Name) and not node.targets[0].id.startswith("_"):
key = node.targets[0].id
# Extract value
try:
value = ast.literal_eval(node.value)
setting = ConfigSetting(
key=key,
value=value,
value_type=self._infer_type(value),
description=self._extract_python_docstring(node),
)
config_file.settings.append(setting)
except (ValueError, TypeError):
# Can't evaluate complex expressions
pass
# Extract value
try:
value = ast.literal_eval(node.value)
setting = ConfigSetting(
key=key,
value=value,
value_type=self._infer_type(value),
description=self._extract_python_docstring(node),
)
config_file.settings.append(setting)
except (ValueError, TypeError):
# Can't evaluate complex expressions
pass
except SyntaxError as e:
config_file.parse_errors.append(f"Python parse error: {str(e)}")