Skip to content

fix(services): remove unjustified type:ignore and narrow bare except - #12

Merged
Harikeshav-R merged 1 commit into
feat/policies-and-loadgenfrom
fix/edge-gateway-type-ignore-loadgen-except
Sep 11, 2026
Merged

Harikeshav-R merged 1 commit into
feat/policies-and-loadgenfrom
fix/edge-gateway-type-ignore-loadgen-except

Conversation

@rsanghvi21

Copy link
Copy Markdown
Collaborator

Build-Plan Step Implemented

  • Step: A1.1/A1.8 (cleanup fix on already-completed services).

Checkpoint Execution & Output

$ uv run pytest tests/unit/services/test_loadgen.py -v -k "not test_run_loadgen_with_owned_client_and_zero_rps"
10 passed in 2.32s   (1 deselected -- pre-existing Windows-local hang, see below)

$ uv run pytest tests/unit --ignore=tests/unit/services/test_edge_gateway.py -k "not test_run_loadgen_with_owned_client_and_zero_rps" --cov=understudy --cov-branch --cov-fail-under=100
191 passed, 100.00% coverage

$ uv run ruff check . && uv run ruff format --check . && uv run mypy --strict src tests && uv run lint-imports && uv run python scripts/check_mocks.py
All green.

Two pre-existing, unrelated items excluded above, both isolated by direct
investigation to the same root cause: constructing a real httpx.AsyncClient()
with no explicit transport= (i.e. httpx's real default transport, not
MockTransport/ASGITransport) triggers a Windows-local-only OpenSSL Uplink
crash between psycopg-binary and httpx on this dev machine. This is not
present on CI (ubuntu-latest, .github/workflows/ci.yml).

  • tests/unit/services/test_edge_gateway.py's client fixture enters
    edge_gateway.app.lifespan, which constructs exactly such a client. I
    verified the two changed lines directly instead, by calling get_items
    and create_item with app.state.http_client mocked and bypassing
    lifespan entirely -- both return the expected dict with no ignore.
  • test_loadgen.py::test_run_loadgen_with_owned_client_and_zero_rps calls
    run_loadgen(config) with no client=, so run_loadgen constructs its
    own default-transport client internally. All 10 other tests in that file
    pass, including the new regression test added by this PR.

ADRs Relied On

  • None.

Mock Registry Disclosures

  • None.

Documentation Updates

  • None required -- internal error-handling and type-safety corrections, no
    documented contract or tunable changed.

Definition of Done

  • Implementation complete for the named build-plan step
  • Unit tests written; 100% line and branch coverage of the added lines
  • make check green (see checkpoint output; two pre-existing Windows-local-only items excluded and independently verified, not related to this change)
  • Checkpoint command run and output matches, OR marked unverified with a reason
  • Docs updated where this change made them untrue (none required)
  • No new # MOCKED: marker without a row in docs/MOCKS.md
  • Conventional commit(s), conventional branch, PR opened, never pushed to main

Context

A /code-review pass against PR #6 flagged two unjustified silencing patterns
(AGENTS.md §5.4): a type: ignore[no-any-return] used twice in
edge_gateway/app.py where a typed local variable is the real fix, and a
bare except Exception in loadgen/runner.py that could mask a genuine bug
as a fake failed-request metric. Both are fixed here with no behavior change
to the legitimate paths (httpx transient errors are still recorded as failed
requests; only non-httpx exceptions now propagate).

Base branch is feat/policies-and-loadgen (PR #6, still open), since
services/ only exists on that branch's stack.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CzBeBUsZmE38K1kWeLMhNh

edge_gateway/app.py's get_items and create_item both silenced
mypy's [no-any-return] on `return data_resp.json()` with a
type: ignore, even though both functions are declared
-> dict[str, Any]. Assign to an explicitly-typed local first instead
-- mypy treats the annotation as authoritative, so the return
type-checks with no ignore needed.

loadgen/runner.py's _execute_single_request caught bare
`except Exception` around a call that can only raise
httpx.RequestError subclasses. A bare catch there would silently
record a real bug (e.g. a TypeError from a malformed RequestSpec) as
a fake "failed request" metric instead of failing the load-gen run
loudly. Narrow to `except httpx.RequestError`.

Implements build-plan step A1.1/A1.8 (fix on already-completed
services).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CzBeBUsZmE38K1kWeLMhNh
@Harikeshav-R
Harikeshav-R merged commit 6fd8885 into feat/policies-and-loadgen Sep 11, 2026
1 check passed
@Harikeshav-R
Harikeshav-R deleted the fix/edge-gateway-type-ignore-loadgen-except branch September 11, 2026 19:49
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