Skip to content

refactor(schemas): replace hand-rolled loop with a list comprehension in normalize_claim_navigation_hints - #299

Merged
dhruvbatra merged 1 commit into
mainfrom
claude/admiring-hawking-48kdt1
Aug 25, 2026
Merged

refactor(schemas): replace hand-rolled loop with a list comprehension in normalize_claim_navigation_hints#299
dhruvbatra merged 1 commit into
mainfrom
claude/admiring-hawking-48kdt1

Conversation

@dhruvbatra

@dhruvbatra dhruvbatra commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

What

normalize_claim_navigation_hints built its result with a manual append-in-a-loop instead of a comprehension, even though the loop body is a single conditional expression per item (None passes through unchanged; everything else gets stripped, and an empty string becomes None).

Why

Small readability win — the loop obscures what is a one-line per-item transformation. Matches this repo's existing style of idiomatic, comprehension-based normalization elsewhere in schemas.py.

Why it's safe

Behavior-preserving: the comprehension produces the exact same value for every element (None -> None; non-None -> hint.strip() or None, matching the original branch-by-branch). Scoped to a single function in a single file, 8 lines removed / 1 added.

Verification:

  • pytest tests/: 322 passed, 21 failed — unchanged from baseline. The 21 failures are this repo's documented pre-existing environment-only Chromium-sandbox failures (no Chromium binary in this sandbox), not caused by this change.
  • ruff check src/ tests/ / ruff format --check: clean

Generated by Claude Code


Note

Low Risk
Behavior-preserving refactor in a single Pydantic field validator with no API or validation rule changes.

Overview
Replaces the manual loop in normalize_claim_navigation_hints on VerifyVisualClaimsInput with a one-line list comprehension. None hints still pass through unchanged; non-None values are still stripped, with empty strings normalized to None.

No validation rules or alignment checks change—only how the per-hint normalization is expressed, aligned with other comprehension-style normalizers in schemas.py.

Reviewed by Cursor Bugbot for commit aa1133e. Bugbot is set up for automated code reviews on this repo. Configure here.

… in normalize_claim_navigation_hints

normalize_claim_navigation_hints built its result with a manual
append-in-a-loop instead of a comprehension, despite the loop body being a
single conditional expression per item (None passes through, everything
else gets stripped, empty strings become None).

Behavior-preserving: the comprehension produces the exact same value for
every element (None -> None; non-None -> hint.strip() or None).

Verification: pytest tests/ -> 322 passed, 21 failed (unchanged from
baseline -- the 21 failures are the repo's documented pre-existing
environment-only Chromium-sandbox failures, not from this change); ruff
check / ruff format --check clean.
@dhruvbatra
dhruvbatra merged commit 5a170e8 into main Aug 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants