You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore: clean up CodeQL py/* quality alerts (unused-import, unused-local-variable, empty-except)
Three CodeQL Code Quality rules cleared in one pass:
1. **py/unused-import** (33 fixes) — `ruff check --select F401 --fix`.
4 in openkb/ (production code, all partial-unused where the line
keeps the names actually used): Console at chat.py:341, SCHEMA_MD
at linter.py:11, ItemHelpers at query.py:116, field at converter.py:6.
29 in tests/ — leftover `import pytest`, `from pathlib import Path`,
and unused mock classes from test scaffolding.
2. **py/unused-local-variable** (5 fixes) — all in tests/:
- tests/test_add_command.py:72, 86 — `result = runner.invoke(...)`
captured but only mock-call assertions matter; dropped the binding.
- tests/test_add_command.py:122 — `as mock_conv` never referenced;
removed the alias from the with-patch.
- tests/test_lint.py:197, 210 — `wiki = _make_wiki(tmp_path)` where
the helper's side effect (creating the dir tree) is what matters;
dropped the binding, kept the call.
3. **py/empty-except** (2 fixes) — both in openkb/agent/tools.py
inside `parse_pages`. The `except ValueError: pass` blocks were
intentionally tolerating malformed segments in user-supplied page
specs ("3-5,7,foo"). Replaced with `contextlib.suppress(ValueError)`,
which signals the intent explicitly and CodeQL no longer flags.
Total: 40 quality alerts → 0. All 329 tests still pass. No behavior
change.
References:
- https://github.com/VectifyAI/OpenKB/security/quality/rules/py/unused-import
- https://github.com/VectifyAI/OpenKB/security/quality/rules/py/unused-local-variable
- https://github.com/VectifyAI/OpenKB/security/quality/rules/py/empty-except
(py/mixed-returns and py/multiple-definition: both 0 hits in the
current codebase, no fixes needed.)
0 commit comments