fix(python): clean up Qodana notices left by PR #106
User description
Summary
Addresses the 18 Qodana notices reported on main after PR #106 (Research Hive v0 roles + capability policy) merged.
| Category | Count | Fix |
|---|---|---|
| Incorrect docstring | 7 | lab_run.py: documented all 7 previously-missing run_lab_unit() parameters (owner, repo, hypothesis_id, agent_id, role, branch, job_id) |
| Accessing a protected member | 4 | findings.py: promoted extract_headings_outside_code_blocks, normalize_heading, escape_md_inline, escape_md_code from private to public — aggregate.py legitimately reuses them cross-module |
| Shadowing names from outer scope | 2 | findings.py: renamed the nested _bullets() loop variables (item→finding, ev→note) so they no longer collide with to_markdown()'s own loop variables |
| Unclear exception clauses | 1 | Not changed — see below |
| Redundant parentheses | 1 | cli.py: dropped redundant parens around a single f-string argument |
| String conversion without dunder method | 1 | research.py: narrowed _validate_schema_version's object-typed value via isinstance(value, int) or isinstance(value, bool), matching the identical bool-exclusion pattern already used in aggregate.py's own schema_version validation |
| Unused local symbols | 1 | lab_run.py: dropped the dead `report: FindingsReport |
| Regular expression can be simplified | 1 | lab_run.py: [^\s] → \S in _SHELL_C_RE |
Not changed: babysit.py:993's except Exception: in _apply_fix(). fix_handler is an arbitrary caller-supplied callable, so catching Exception broadly (already documented at the call site) is correct, not a bug — narrowing it would let an unanticipated fix-handler failure silently escape the babysit cycle. The identical pattern is already used unflagged elsewhere in this codebase (lab_jobs.py:275,523, watchlist.py:434,557); Qodana only flagged this one instance because its PR-mode scan is diff-scoped to PR #106's changed lines.
Test plan
-
python -m pytest— 809 passed -
ruff check— clean -
python -m mypy(strict) on all touched files — clean - Ran
qodana scan --linter qodana-python-community --project-dir=python --within-docker=truelocally, matching CI's exact linter/profile config, against the whole project: none of the 8 originally flagged categories remain anywhere inpython/. The scan does surface 203 unrelated findings (PyTypeHintsInspection,PyClassHasNoInitInspection,PyInconsistentReturnsInspection— mostly on@dataclass(frozen=True, slots=True)classes and PEP 604 unions) but those are pre-existing and hit 129 files this patch never touched, confirming no regression. - CI on PR
🤖 Generated with Claude Code
https://claude.ai/code/session_01RTm7Zmpvvk1z4r5xPprmhZ
Summary by cubic
Resolves the 18 Qodana notices from PR #106 in the Python package. Most fixes are cosmetic; behavior is unchanged except _validate_schema_version, which now uses the same bool-exclusion pattern as aggregate.py.
Refactors
- Documented the 7 previously undocumented
run_lab_unit()parameters and removed a dead pre-assignment. - Made four
findings.pyhelpers public sinceaggregate.pylegitimately reuses them cross-module. - Renamed nested loop variables in
findings.pyto stop shadowing the outer scope, and simplified_SHELL_C_REinlab_run.py. - Left
babysit.py's broadexcept Exceptionuntouched; it intentionally wraps an arbitrary caller-supplied callable, and the same pattern is already used unflagged inlab_jobs.pyandwatchlist.py.
CodeAnt-AI Description
Resolve static-analysis issues without changing runtime behavior
What Changed
- Findings and aggregate report generation now use shared Markdown helpers without altering report content or validation.
- Lab-run documentation now describes all required run parameters, and an unused initialization has been removed.
- Schema-version validation continues to reject booleans while accepting valid integer values.
- Shell command matching and command-line help formatting were simplified without changing their behavior.
Impact
✅ Cleaner quality checks
✅ Consistent findings and aggregate reports
✅ Clearer lab-run documentation
💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
@codeant-ai ask: Your question here
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
@codeant-ai ask: Can you suggest a safer alternative to storing this secret?
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
@codeant-ai: Your feedback here
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
@codeant-ai: Do not flag unused imports.
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
@codeant-ai: review
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.